[Form] Renamed option 'primitive' to 'single_control'
This commit is contained in:
parent
167e64f799
commit
d3bb4d085c
|
@ -370,7 +370,7 @@
|
|||
themes.
|
||||
|
||||
The "field_widget" and all references to it should be renamed to
|
||||
"form_widget_primitive":
|
||||
"form_widget_single_control":
|
||||
|
||||
Before:
|
||||
|
||||
|
@ -389,7 +389,7 @@
|
|||
{% block url_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('url') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock url_widget %}
|
||||
```
|
||||
|
@ -397,7 +397,7 @@
|
|||
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":
|
||||
Boolean variable "single_control":
|
||||
|
||||
Before:
|
||||
|
||||
|
@ -420,7 +420,7 @@
|
|||
```
|
||||
{% block form_errors %}
|
||||
{% spaceless %}
|
||||
{% if primitive %}
|
||||
{% if single_control %}
|
||||
... field code ...
|
||||
{% else %}
|
||||
... form code ...
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
{% block form_widget %}
|
||||
{% spaceless %}
|
||||
{% if primitive %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{% if single_control %}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% else %}
|
||||
{{ block('form_widget_complex') }}
|
||||
{{ block('form_widget_compound') }}
|
||||
{% endif %}
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget %}
|
||||
|
||||
{% block form_widget_primitive %}
|
||||
{% block form_widget_single_control %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('text') %}
|
||||
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_primitive %}
|
||||
{% endblock form_widget_single_control %}
|
||||
|
||||
{% block form_widget_complex %}
|
||||
{% block form_widget_compound %}
|
||||
{% spaceless %}
|
||||
<div {{ block('widget_container_attributes') }}>
|
||||
{{ block('form_rows') }}
|
||||
{{ form_rest(form) }}
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_complex %}
|
||||
{% endblock form_widget_compound %}
|
||||
|
||||
{% block collection_widget %}
|
||||
{% spaceless %}
|
||||
|
@ -112,7 +112,7 @@
|
|||
{% block datetime_widget %}
|
||||
{% spaceless %}
|
||||
{% if widget == 'single_text' %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% else %}
|
||||
<div {{ block('widget_container_attributes') }}>
|
||||
{{ form_errors(form.date) }}
|
||||
|
@ -127,7 +127,7 @@
|
|||
{% block date_widget %}
|
||||
{% spaceless %}
|
||||
{% if widget == 'single_text' %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% else %}
|
||||
<div {{ block('widget_container_attributes') }}>
|
||||
{{ date_pattern|replace({
|
||||
|
@ -143,7 +143,7 @@
|
|||
{% block time_widget %}
|
||||
{% spaceless %}
|
||||
{% if widget == 'single_text' %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% else %}
|
||||
<div {{ block('widget_container_attributes') }}>
|
||||
{{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
|
||||
|
@ -156,62 +156,62 @@
|
|||
{% spaceless %}
|
||||
{# type="number" doesn't work with floats #}
|
||||
{% set type = type|default('text') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock number_widget %}
|
||||
|
||||
{% block integer_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('number') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock integer_widget %}
|
||||
|
||||
{% block money_widget %}
|
||||
{% spaceless %}
|
||||
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_primitive') })|raw }}
|
||||
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_single_control') })|raw }}
|
||||
{% endspaceless %}
|
||||
{% endblock money_widget %}
|
||||
|
||||
{% block url_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('url') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock url_widget %}
|
||||
|
||||
{% block search_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('search') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock search_widget %}
|
||||
|
||||
{% block percent_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('text') %}
|
||||
{{ block('form_widget_primitive') }} %
|
||||
{{ block('form_widget_single_control') }} %
|
||||
{% endspaceless %}
|
||||
{% endblock percent_widget %}
|
||||
|
||||
{% block password_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('password') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock password_widget %}
|
||||
|
||||
{% block hidden_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('hidden') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock hidden_widget %}
|
||||
|
||||
{% block email_widget %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('email') %}
|
||||
{{ block('form_widget_primitive') }}
|
||||
{{ block('form_widget_single_control') }}
|
||||
{% endspaceless %}
|
||||
{% endblock email_widget %}
|
||||
|
||||
|
@ -219,7 +219,7 @@
|
|||
|
||||
{% block form_label %}
|
||||
{% spaceless %}
|
||||
{% if primitive %}
|
||||
{% if single_control %}
|
||||
{% set label_attr = label_attr|merge({'for': id}) %}
|
||||
{% endif %}
|
||||
{% if required %}
|
||||
|
@ -241,9 +241,11 @@
|
|||
{% spaceless %}
|
||||
<div>
|
||||
{{ form_label(form, label|default(null)) }}
|
||||
{# If the child is a form, the errors are rendered inside the container #}
|
||||
{# see block form_rows #}
|
||||
{% if primitive %}
|
||||
{#
|
||||
If the child is a compound form, the errors are rendered inside
|
||||
the container. See also block form_rows.
|
||||
#}
|
||||
{% if single_control %}
|
||||
{{ form_errors(form) }}
|
||||
{% endif %}
|
||||
{{ form_widget(form) }}
|
||||
|
@ -318,7 +320,7 @@
|
|||
|
||||
{% block generic_label %}{{ block('form_label') }}{% endblock %}
|
||||
{% block widget_choice_options %}{{ block('choice_widget_options') }}{% endblock %}
|
||||
{% block field_widget %}{{ block('form_widget_primitive') }}{% endblock %}
|
||||
{% block field_widget %}{{ block('form_widget_single_control') }}{% endblock %}
|
||||
{% block field_label %}{{ block('form_label') }}{% endblock %}
|
||||
{% block field_row %}{{ block('form_row') }}{% endblock %}
|
||||
{% block field_enctype %}{{ block('form_enctype') }}{% endblock %}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{ form_label(form, label|default(null)) }}
|
||||
</td>
|
||||
<td>
|
||||
{% if primitive %}
|
||||
{% if single_control %}
|
||||
{{ form_errors(form) }}
|
||||
{% endif %}
|
||||
{{ form_widget(form) }}
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
{% block form_errors %}
|
||||
{% spaceless %}
|
||||
{% if primitive %}
|
||||
{% if single_control %}
|
||||
{{ parent() }}
|
||||
{% else %}
|
||||
{% if errors|length > 0 %}
|
||||
|
@ -42,11 +42,11 @@
|
|||
{% endspaceless %}
|
||||
{% endblock hidden_row %}
|
||||
|
||||
{% block form_widget_complex %}
|
||||
{% block form_widget_compound %}
|
||||
{% spaceless %}
|
||||
<table {{ block('widget_container_attributes') }}>
|
||||
{{ block('form_rows') }}
|
||||
{{ form_rest(form) }}
|
||||
</table>
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_complex %}
|
||||
{% endblock form_widget_compound %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% block form_widget_primitive %}
|
||||
{% block form_widget_single_control %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('text') %}
|
||||
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_primitive %}
|
||||
{% endblock form_widget_single_control %}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% extends 'form_div_layout.html.twig' %}
|
||||
|
||||
{% block form_widget_primitive %}
|
||||
{% block form_widget_single_control %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('text') %}
|
||||
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_primitive %}
|
||||
{% endblock form_widget_single_control %}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% use 'form_div_layout.html.twig' %}
|
||||
|
||||
{% block form_widget_primitive %}
|
||||
{% block form_widget_single_control %}
|
||||
{% spaceless %}
|
||||
{% set type = type|default('text') %}
|
||||
<input type="{{ type }}" {{ block('widget_attributes') }} value="{{ value }}" rel="theme" />
|
||||
{% endspaceless %}
|
||||
{% endblock form_widget_primitive %}
|
||||
{% endblock form_widget_single_control %}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php if ($widget == 'single_text'): ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_primitive'); ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control'); ?>
|
||||
<?php else: ?>
|
||||
<div <?php echo $view['form']->renderBlock('widget_container_attributes') ?>>
|
||||
<?php echo str_replace(array('{{ year }}', '{{ month }}', '{{ day }}'), array(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php if ($widget == 'single_text'): ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_primitive'); ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control'); ?>
|
||||
<?php else: ?>
|
||||
<div <?php echo $view['form']->renderBlock('widget_container_attributes') ?>>
|
||||
<?php echo $view['form']->widget($form['date']).' '.$view['form']->widget($form['time']) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : 'email')) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : 'email')) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive') ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control') ?>
|
|
@ -1,3 +1,3 @@
|
|||
<?php if ($required) { $label_attr['class'] = trim((isset($label_attr['class']) ? $label_attr['class'] : '').' required'); } ?>
|
||||
<?php if ($primitive) { $label_attr['for'] = $id; } ?>
|
||||
<?php if ($single_control) { $label_attr['for'] = $id; } ?>
|
||||
<label <?php foreach($label_attr as $k => $v) { printf('%s="%s" ', $view->escape($k), $view->escape($v)); } ?>><?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div>
|
||||
<?php echo $view['form']->label($form, isset($label) ? $label : null) ?>
|
||||
<?php if ($primitive): ?>
|
||||
<?php if ($single_control): ?>
|
||||
<?php echo $view['form']->errors($form) ?>
|
||||
<?php endif ?>
|
||||
<?php echo $view['form']->widget($form) ?>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php if ($primitive): ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_primitive')?>
|
||||
<?php if ($single_control): ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control')?>
|
||||
<?php else: ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_complex')?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_compound')?>
|
||||
<?php endif ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "hidden")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "hidden")) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "number")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "number")) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo str_replace('{{ widget }}', $view['form']->renderBlock('form_widget_primitive'), $money_pattern) ?>
|
||||
<?php echo str_replace('{{ widget }}', $view['form']->renderBlock('form_widget_single_control'), $money_pattern) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "text")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "text")) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "password")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "password")) ?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "text")) ?> %
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "text")) ?> %
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "search")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "search")) ?>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php if ($widget == 'single_text'): ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_primitive'); ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control'); ?>
|
||||
<?php else: ?>
|
||||
<div <?php echo $view['form']->renderBlock('widget_container_attributes') ?>>
|
||||
<?php
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $view['form']->renderBlock('form_widget_primitive', array('type' => isset($type) ? $type : "url")) ?>
|
||||
<?php echo $view['form']->renderBlock('form_widget_single_control', array('type' => isset($type) ? $type : "url")) ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php if ($primitive): ?>
|
||||
<?php if ($single_control): ?>
|
||||
<?php if ($errors): ?>
|
||||
<ul>
|
||||
<?php foreach ($errors as $error): ?>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<?php echo $view['form']->label($form, isset($label) ? $label : null) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($primitive): ?>
|
||||
<?php if ($single_control): ?>
|
||||
<?php echo $view['form']->errors($form) ?>
|
||||
<?php endif ?>
|
||||
<?php echo $view['form']->widget($form) ?>
|
||||
|
|
|
@ -60,10 +60,10 @@ CHANGELOG
|
|||
* deprecated FieldType and merged it into FormType
|
||||
* [BC BREAK] renamed theme blocks
|
||||
* "field_*" to "form_*"
|
||||
* "field_widget" to "form_widget_primitive"
|
||||
* "field_widget" to "form_widget_single_control"
|
||||
* "widget_choice_options" to "choice_widget_options"
|
||||
* "generic_label" to "form_label"
|
||||
* added theme blocks "form_widget_complex", "choice_widget_expanded" and
|
||||
* added theme blocks "form_widget_compound", "choice_widget_expanded" and
|
||||
"choice_widget_collapsed" to make theming more modular
|
||||
* ValidatorTypeGuesser now guesses "collection" for array type constraint
|
||||
* added method `guessPattern` to FormTypeGuesserInterface to guess which pattern to use in the HTML5 attribute "pattern"
|
||||
|
|
|
@ -51,9 +51,9 @@ class CheckboxType extends AbstractType
|
|||
};
|
||||
|
||||
return array(
|
||||
'value' => '1',
|
||||
'empty_data' => $emptyData,
|
||||
'primitive' => true,
|
||||
'value' => '1',
|
||||
'empty_data' => $emptyData,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ class ChoiceType extends AbstractType
|
|||
return $options['required'] ? null : '';
|
||||
};
|
||||
|
||||
$primitive = function (Options $options) {
|
||||
$singleControl = function (Options $options) {
|
||||
return !$options['expanded'];
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@ class ChoiceType extends AbstractType
|
|||
'empty_data' => $emptyData,
|
||||
'empty_value' => $emptyValue,
|
||||
'error_bubbling' => false,
|
||||
'primitive' => $primitive,
|
||||
'single_control' => $singleControl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class DateTimeType extends AbstractType
|
|||
*/
|
||||
public function getDefaultOptions()
|
||||
{
|
||||
$primitive = function (Options $options) {
|
||||
$singleControl = function (Options $options) {
|
||||
return $options['widget'] === 'single_text';
|
||||
};
|
||||
|
||||
|
@ -163,7 +163,7 @@ class DateTimeType extends AbstractType
|
|||
// representation is not \DateTime, but an array, we need to unset
|
||||
// this option.
|
||||
'data_class' => null,
|
||||
'primitive' => $primitive,
|
||||
'single_control' => $singleControl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ class DateType extends AbstractType
|
|||
*/
|
||||
public function getDefaultOptions()
|
||||
{
|
||||
$primitive = function (Options $options) {
|
||||
$singleControl = function (Options $options) {
|
||||
return $options['widget'] === 'single_text';
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ class DateType extends AbstractType
|
|||
// representation is not \DateTime, but an array, we need to unset
|
||||
// this option.
|
||||
'data_class' => null,
|
||||
'primitive' => $primitive,
|
||||
'single_control' => $singleControl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class FileType extends AbstractType
|
|||
public function getDefaultOptions()
|
||||
{
|
||||
return array(
|
||||
'primitive' => true,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class FormType extends AbstractType
|
|||
->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])
|
||||
->setAttribute('translation_domain', $options['translation_domain'])
|
||||
->setAttribute('virtual', $options['virtual'])
|
||||
->setAttribute('primitive', $options['primitive'])
|
||||
->setAttribute('single_control', $options['single_control'])
|
||||
->setData($options['data'])
|
||||
->setDataMapper(new PropertyPathMapper($options['data_class']))
|
||||
->addEventSubscriber(new ValidationListener())
|
||||
|
@ -133,7 +133,7 @@ class FormType extends AbstractType
|
|||
->set('multipart', false)
|
||||
->set('attr', $form->getAttribute('attr'))
|
||||
->set('label_attr', $form->getAttribute('label_attr'))
|
||||
->set('primitive', $form->getAttribute('primitive'))
|
||||
->set('single_control', $form->getAttribute('single_control'))
|
||||
->set('types', $types)
|
||||
->set('translation_domain', $form->getAttribute('translation_domain'))
|
||||
;
|
||||
|
@ -211,7 +211,7 @@ class FormType extends AbstractType
|
|||
'attr' => array(),
|
||||
'label_attr' => array(),
|
||||
'virtual' => false,
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
'invalid_message' => 'This value is not valid.',
|
||||
'invalid_message_parameters' => array(),
|
||||
'translation_domain' => 'messages',
|
||||
|
|
|
@ -25,7 +25,7 @@ class HiddenType extends AbstractType
|
|||
'required' => false,
|
||||
// Pass errors to the parent
|
||||
'error_bubbling' => true,
|
||||
'primitive' => true,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ class IntegerType extends AbstractType
|
|||
{
|
||||
return array(
|
||||
// default precision is locale specific (usually around 3)
|
||||
'precision' => null,
|
||||
'grouping' => false,
|
||||
'precision' => null,
|
||||
'grouping' => false,
|
||||
// Integer cast rounds towards 0, so do the same when displaying fractions
|
||||
'rounding_mode' => \NumberFormatter::ROUND_DOWN,
|
||||
'primitive' => true,
|
||||
'rounding_mode' => \NumberFormatter::ROUND_DOWN,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ class MoneyType extends AbstractType
|
|||
public function getDefaultOptions()
|
||||
{
|
||||
return array(
|
||||
'precision' => 2,
|
||||
'grouping' => false,
|
||||
'divisor' => 1,
|
||||
'currency' => 'EUR',
|
||||
'primitive' => true,
|
||||
'precision' => 2,
|
||||
'grouping' => false,
|
||||
'divisor' => 1,
|
||||
'currency' => 'EUR',
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ class NumberType extends AbstractType
|
|||
{
|
||||
return array(
|
||||
// default precision is locale specific (usually around 3)
|
||||
'precision' => null,
|
||||
'grouping' => false,
|
||||
'rounding_mode' => \NumberFormatter::ROUND_HALFUP,
|
||||
'primitive' => true,
|
||||
'precision' => null,
|
||||
'grouping' => false,
|
||||
'rounding_mode' => \NumberFormatter::ROUND_HALFUP,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ class PercentType extends AbstractType
|
|||
public function getDefaultOptions()
|
||||
{
|
||||
return array(
|
||||
'precision' => 0,
|
||||
'type' => 'fractional',
|
||||
'primitive' => true,
|
||||
'precision' => 0,
|
||||
'type' => 'fractional',
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class TextType extends AbstractType
|
|||
public function getDefaultOptions()
|
||||
{
|
||||
return array(
|
||||
'primitive' => true,
|
||||
'single_control' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class TimeType extends AbstractType
|
|||
*/
|
||||
public function getDefaultOptions()
|
||||
{
|
||||
$primitive = function (Options $options) {
|
||||
$singleControl = function (Options $options) {
|
||||
return $options['widget'] === 'single_text';
|
||||
};
|
||||
|
||||
|
@ -160,7 +160,7 @@ class TimeType extends AbstractType
|
|||
// representation is not \DateTime, but an array, we need to unset
|
||||
// this option.
|
||||
'data_class' => null,
|
||||
'primitive' => $primitive,
|
||||
'single_control' => $singleControl,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class CsrfValidationListener implements EventSubscriberInterface
|
|||
$form = $event->getForm();
|
||||
$data = $event->getData();
|
||||
|
||||
if ($form->isRoot() && !$form->getAttribute('primitive')) {
|
||||
if ($form->isRoot() && !$form->getAttribute('single_control')) {
|
||||
if (!isset($data[$this->fieldName]) || !$this->csrfProvider->isCsrfTokenValid($this->intention, $data[$this->fieldName])) {
|
||||
$form->addError(new FormError('The CSRF token is invalid. Please try to resubmit the form'));
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
|||
*/
|
||||
public function buildViewBottomUp(FormView $view, FormInterface $form)
|
||||
{
|
||||
if (!$view->hasParent() && !$form->getAttribute('primitive') && $form->hasAttribute('csrf_field_name')) {
|
||||
if (!$view->hasParent() && !$form->getAttribute('single_control') && $form->hasAttribute('csrf_field_name')) {
|
||||
$name = $form->getAttribute('csrf_field_name');
|
||||
$csrfProvider = $form->getAttribute('csrf_provider');
|
||||
$intention = $form->getAttribute('csrf_intention');
|
||||
|
|
|
@ -56,26 +56,26 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
));
|
||||
}
|
||||
|
||||
public function testCsrfProtectionByDefaultIfRootAndNotPrimitive()
|
||||
public function testCsrfProtectionByDefaultIfRootAndNotSingleControl()
|
||||
{
|
||||
$view = $this->factory
|
||||
->create('form', null, array(
|
||||
'csrf_field_name' => 'csrf',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
))
|
||||
->createView();
|
||||
|
||||
$this->assertTrue($view->hasChild('csrf'));
|
||||
}
|
||||
|
||||
public function testNoCsrfProtectionByDefaultIfNotPrimitiveButNotRoot()
|
||||
public function testNoCsrfProtectionByDefaultIfNotSingleControlButNotRoot()
|
||||
{
|
||||
$view = $this->factory
|
||||
->createNamedBuilder('form', 'root')
|
||||
->add($this->factory
|
||||
->createNamedBuilder('form', 'form', null, array(
|
||||
'csrf_field_name' => 'csrf',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
))
|
||||
)
|
||||
->getForm()
|
||||
|
@ -85,12 +85,12 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
$this->assertFalse($view->hasChild('csrf'));
|
||||
}
|
||||
|
||||
public function testNoCsrfProtectionByDefaultIfRootButPrimitive()
|
||||
public function testNoCsrfProtectionByDefaultIfRootButSingleControl()
|
||||
{
|
||||
$view = $this->factory
|
||||
->create('form', null, array(
|
||||
'csrf_field_name' => 'csrf',
|
||||
'primitive' => true,
|
||||
'single_control' => true,
|
||||
))
|
||||
->createView();
|
||||
|
||||
|
@ -103,7 +103,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
->create('form', null, array(
|
||||
'csrf_field_name' => 'csrf',
|
||||
'csrf_protection' => false,
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
))
|
||||
->createView();
|
||||
|
||||
|
@ -122,7 +122,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
'csrf_field_name' => 'csrf',
|
||||
'csrf_provider' => $this->csrfProvider,
|
||||
'intention' => '%INTENTION%',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
))
|
||||
->createView();
|
||||
|
||||
|
@ -140,7 +140,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
/**
|
||||
* @dataProvider provideBoolean
|
||||
*/
|
||||
public function testValidateTokenOnBindIfRootAndNotPrimitive($valid)
|
||||
public function testValidateTokenOnBindIfRootAndNotSingleControl($valid)
|
||||
{
|
||||
$this->csrfProvider->expects($this->once())
|
||||
->method('isCsrfTokenValid')
|
||||
|
@ -152,7 +152,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
'csrf_field_name' => 'csrf',
|
||||
'csrf_provider' => $this->csrfProvider,
|
||||
'intention' => '%INTENTION%',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
));
|
||||
|
||||
$form->bind(array(
|
||||
|
@ -167,7 +167,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
$this->assertSame($valid, $form->isValid());
|
||||
}
|
||||
|
||||
public function testFailIfRootAndNotPrimitiveAndTokenMissing()
|
||||
public function testFailIfRootAndNotSingleControlAndTokenMissing()
|
||||
{
|
||||
$this->csrfProvider->expects($this->never())
|
||||
->method('isCsrfTokenValid');
|
||||
|
@ -177,7 +177,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
'csrf_field_name' => 'csrf',
|
||||
'csrf_provider' => $this->csrfProvider,
|
||||
'intention' => '%INTENTION%',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
));
|
||||
|
||||
$form->bind(array(
|
||||
|
@ -192,7 +192,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
$this->assertFalse($form->isValid());
|
||||
}
|
||||
|
||||
public function testDontValidateTokenIfNotPrimitiveButNoRoot()
|
||||
public function testDontValidateTokenIfNotSingleControlButNoRoot()
|
||||
{
|
||||
$this->csrfProvider->expects($this->never())
|
||||
->method('isCsrfTokenValid');
|
||||
|
@ -204,7 +204,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
'csrf_field_name' => 'csrf',
|
||||
'csrf_provider' => $this->csrfProvider,
|
||||
'intention' => '%INTENTION%',
|
||||
'primitive' => false,
|
||||
'single_control' => false,
|
||||
))
|
||||
)
|
||||
->getForm()
|
||||
|
@ -216,7 +216,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
));
|
||||
}
|
||||
|
||||
public function testDontValidateTokenIfRootButPrimitive()
|
||||
public function testDontValidateTokenIfRootButSingleControl()
|
||||
{
|
||||
$this->csrfProvider->expects($this->never())
|
||||
->method('isCsrfTokenValid');
|
||||
|
@ -226,7 +226,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase
|
|||
'csrf_field_name' => 'csrf',
|
||||
'csrf_provider' => $this->csrfProvider,
|
||||
'intention' => '%INTENTION%',
|
||||
'primitive' => true,
|
||||
'single_control' => true,
|
||||
));
|
||||
|
||||
$form->bind(array(
|
||||
|
|
Reference in New Issue