diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md
index 29baddf4f6..e8f9ca869b 100644
--- a/UPGRADE-2.1.md
+++ b/UPGRADE-2.1.md
@@ -102,7 +102,7 @@
```
* The custom factories for the firewall configuration are now
registered during the build method of bundles instead of being registered
- by the end-user. This means that you will you need to remove the 'factories'
+ by the end-user. This means that you will you need to remove the 'factories'
keys in your security configuration.
* The Firewall listener is now registered after the Router listener. This
@@ -313,29 +313,29 @@
return isset($options['widget']) && 'single_text' === $options['widget'] ? 'text' : 'choice';
}
```
-
+
* The methods `getDefaultOptions()` and `getAllowedOptionValues()` of form
types no longer receive an option array.
-
+
You can specify options that depend on other options using closures instead.
-
+
Before:
-
+
```
public function getDefaultOptions(array $options)
{
$defaultOptions = array();
-
+
if ($options['multiple']) {
$defaultOptions['empty_data'] = array();
}
-
+
return $defaultOptions;
}
```
-
+
After:
-
+
```
public function getDefaultOptions()
{
@@ -346,7 +346,7 @@
);
}
```
-
+
The second argument `$previousValue` does not have to be specified if not
needed.
@@ -366,29 +366,92 @@
(or any other of the BIND events). In case you used the CallbackValidator
class, you should now pass the callback directly to `addEventListener`.
- * simplified CSRF protection and removed the csrf type
+ * Since FormType and FieldType were merged, you need to adapt your form
+ themes.
- * deprecated FieldType and merged it into FormType
+ The "field_widget" and all references to it should be renamed to
+ "form_widget_primitive":
+
+ Before:
+
+ ```
+ {% block url_widget %}
+ {% spaceless %}
+ {% set type = type|default('url') %}
+ {{ block('field_widget') }}
+ {% endspaceless %}
+ {% endblock url_widget %}
+ ```
+
+ After:
+
+ ```
+ {% block url_widget %}
+ {% spaceless %}
+ {% set type = type|default('url') %}
+ {{ block('form_widget_primitive') }}
+ {% endspaceless %}
+ {% endblock url_widget %}
+ ```
+
+ All other "field_*" blocks and references to them should be renamed to
+ "form_*". If you previously defined both a "field_*" and a "form_*"
+ block, you can merge them into a single "form_*" block and check the new
+ Boolean variable "primitive":
+
+ Before:
+
+ ```
+ {% block form_errors %}
+ {% spaceless %}
+ ... form code ...
+ {% endspaceless %}
+ {% endblock form_errors %}
+
+ {% block field_errors %}
+ {% spaceless %}
+ ... field code ...
+ {% endspaceless %}
+ {% endblock field_errors %}
+ ```
+
+ After:
+
+ ```
+ {% block form_errors %}
+ {% spaceless %}
+ {% if primitive %}
+ ... field code ...
+ {% else %}
+ ... form code ...
+ {% endif %}
+ {% endspaceless %}
+ {% endblock form_errors %}
+ ```
+
+ Furthermore, the block "generic_label" was merged into "form_label". You
+ should now override "form_label" in order to customize labels.
+
+ Last but not least, the block "widget_choice_options" was renamed to
+ "choice_widget_options" to be consistent with the rest of the default
+ theme.
- * [BC BREAK] renamed "field_*" theme blocks to "form_*" and "field_widget" to
- "input"
-
* The method `guessMinLength()` of FormTypeGuesserInterface was deprecated
and will be removed in Symfony 2.3. You should use the new method
`guessPattern()` instead which may return any regular expression that
is inserted in the HTML5 attribute "pattern".
-
+
Before:
-
+
public function guessMinLength($class, $property)
{
if (/* condition */) {
return new ValueGuess($minLength, Guess::LOW_CONFIDENCE);
}
}
-
+
After:
-
+
public function guessPattern($class, $property)
{
if (/* condition */) {
@@ -470,7 +533,7 @@
`validate` and its return value was dropped.
`ConstraintValidator` still contains the deprecated `isValid` method and
- forwards `validate` calls to `isValid` by default. This BC layer will be
+ forwards `validate` calls to `isValid` by default. This BC layer will be
removed in Symfony 2.3. You are advised to rename your methods. You should
also remove the return values, which have never been used by the framework.
@@ -500,7 +563,7 @@
$this->context->addViolation($constraint->message, array(
'{{ value }}' => $value,
));
-
+
return;
}
}
diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
index 46420a7122..8fe3d004fa 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
@@ -2,17 +2,30 @@
{% block form_widget %}
{% spaceless %}
- {% if form.children|length > 0 %}
-
{{ form_label(form, label|default(null)) }}
- {% if form.children|length == 0 %}
+ {# If the child is a form, the errors are rendered inside the container #}
+ {# see block form_rows #}
+ {% if primitive %}
{{ form_errors(form) }}
{% endif %}
{{ form_widget(form) }}
@@ -247,10 +270,8 @@
{% for error in errors %}