<commit_before># Form Bundle for Sulu

Simple handling from Symfony Forms in [Sulu.io](http://sulu.io).  
You can use the Bundle to handle forms which are directly integrated in a Sulu page
or for ajax loaded forms.

## Installation

Add to AbstractKernel (app/AbstractKernel.php)

``` php
    new L91\Sulu\Bundle\FormBundle\L91SuluFormBundle(),
```

## Config

add the following config to `app/config/config.yml`

``` yml
l91_sulu_form:
    mail_helper:
        from: %parameter_recommended_for_from%
        to: %parameter_recommended_for_to%
```

## Concept

### Cacheable Items:

The Template itself should be cached also the form fields.

 - Template
 - Form Fields

### Uncacheable Items

 - Form CSRF Token

### Solutions

1. Load an CSRF Token over Ajax
2. Load CSRF Token in uncached ESI 

## Example Template

The following is showing an example how you can use the bundle.

### Basic Sulu Template

``` xml
<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">

    <key>pages_template_key</key>

    <view>ClientWebsiteBundle:templates:pages_template_key</view>
    <controller>L91SuluFormBundle:Form:form</controller>
    <cacheLifetime>2400</cacheLifetime>

    <meta>
        <title lang="de">Form</title>
        <title lang="en">Form</title>
    </meta>

    <properties>
        <property name="title" type="text_line" mandatory="true"><commit_msg>update readme add composer installation and add hint for ajax loaded form<commit_after># Form Bundle for Sulu

Simple handling from Symfony Forms in [Sulu.io](http://sulu.io).  
You can use the Bundle to handle forms which are directly integrated in a Sulu page
or for ajax loaded forms.

## Installation

Use composer to install this Bundle:

``` json
{
    "require": {
        "l91/sulu-form-bundle": "~0.1"
    }
}
```

or

``` bash
    composer require l91/sulu-form-bundle:~0.1
```

Add to AbstractKernel (app/AbstractKernel.php)

``` php
    new L91\Sulu\Bundle\FormBundle\L91SuluFormBundle(),
```

## Config

add the following config to `app/config/config.yml`

``` yml
l91_sulu_form:
    mail_helper:
        from: %parameter_recommended_for_from%
        to: %parameter_recommended_for_to%
```

## Concept

### Cacheable Items:

The Template itself should be cached also the form fields.

 - Template
 - Form Fields

### Uncacheable Items

 - Form CSRF Token

### Solutions

1. Load an CSRF Token over Ajax
2. Load CSRF Token in uncached ESI 

## Example Template

The following is showing an example how you can use the bundle.

### Basic Sulu Template

Sulu template is not needed when using a ajax loaded form.

``` xml
<?xml version="1.0" ?>
<template xmlns="http://schemas.sulu.io/template/template"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">

    <key>pages_template_key</key>

    <view>ClientWebsiteBundle:templates:pages_template_key</view>
    <controller>L91SuluFormBundle:Form:form</controller>
    <cacheLifetime>2400</cacheLifetime>

    <meta>
        <title lang="de">Form</title>
        <title lang="en">Form</title>
    </meta>

    <properties>
        <property name="title" type="text_line" mandatory="true">
{'fraction_non_alphanumeric': 0.12214842622004042, 'fraction_numerical': 0.01559341611319665, 'mean_word_length': 3.6810810810810812, 'pattern_counts': {'":': 2, '<': 39, '<?xml version=': 2, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4166577', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1090, 'n_words': 298}