Skip to content

Commit

Permalink
[Form] Fixed results of the FieldType+FormType merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Apr 27, 2012
1 parent a01dec0 commit eb75ab1
Show file tree
Hide file tree
Showing 59 changed files with 396 additions and 273 deletions.
105 changes: 84 additions & 21 deletions UPGRADE-2.1.md
Expand Up @@ -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
Expand Down Expand Up @@ -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()
{
Expand All @@ -346,7 +346,7 @@
);
}
```

The second argument `$previousValue` does not have to be specified if not
needed.

Expand All @@ -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.

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 %}
* deprecated FieldType and merged it into FormType
{% 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 */) {
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -500,7 +563,7 @@
$this->context->addViolation($constraint->message, array(
'{{ value }}' => $value,
));
return;
}
}
Expand Down

0 comments on commit eb75ab1

Please sign in to comment.