[Form] Changed getDefaultOptions() to setDefaultOptions(OptionsResolver $resolver) in FormTypeInterface
This commit is contained in:
parent
b4e8bcfc5a
commit
027259eba4
111
UPGRADE-2.1.md
111
UPGRADE-2.1.md
|
@ -313,42 +313,6 @@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* 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()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'empty_data' => function (Options $options, $previousValue) {
|
|
||||||
return $options['multiple'] ? array() : $previousValue;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The second argument `$previousValue` does not have to be specified if not
|
|
||||||
needed.
|
|
||||||
|
|
||||||
* The `add()`, `remove()`, `setParent()`, `bind()` and `setData()` methods in
|
* The `add()`, `remove()`, `setParent()`, `bind()` and `setData()` methods in
|
||||||
the Form class now throw an exception if the form is already bound.
|
the Form class now throw an exception if the form is already bound.
|
||||||
|
|
||||||
|
@ -570,6 +534,81 @@
|
||||||
));
|
));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* The following methods of `FormTypeInterface` and `FormTypeExtensionInterface`
|
||||||
|
are deprecated and will be removed in Symfony 2.3:
|
||||||
|
|
||||||
|
* `getDefaultOptions`
|
||||||
|
* `getAllowedOptionValues`
|
||||||
|
|
||||||
|
You should use the newly added `setDefaultOptions` instead, which gives you
|
||||||
|
access to the OptionsResolver instance and with that a lot more power.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'gender' => 'male',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllowedOptionValues(array $options)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'gender' => array('male', 'female'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```
|
||||||
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'gender' => 'male',
|
||||||
|
));
|
||||||
|
|
||||||
|
$resolver->setAllowedValues(array(
|
||||||
|
'gender' => array('male', 'female'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can specify options that depend on other options using closures.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```
|
||||||
|
public function getDefaultOptions(array $options)
|
||||||
|
{
|
||||||
|
$defaultOptions = array();
|
||||||
|
|
||||||
|
if ($options['multiple']) {
|
||||||
|
$defaultOptions['empty_data'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $defaultOptions;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```
|
||||||
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'empty_data' => function (Options $options, $value) {
|
||||||
|
return $options['multiple'] ? array() : $value;
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The second argument `$value` contains the current default value and
|
||||||
|
does not have to be specified if not needed.
|
||||||
|
|
||||||
### Validator
|
### Validator
|
||||||
|
|
||||||
* The methods `setMessage()`, `getMessageTemplate()` and
|
* The methods `setMessage()`, `getMessageTemplate()` and
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Symfony\Bridge\Doctrine\Form\EventListener\MergeDoctrineCollectionListener;
|
||||||
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
abstract class DoctrineType extends AbstractType
|
abstract class DoctrineType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -43,7 +44,7 @@ abstract class DoctrineType extends AbstractType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$registry = $this->registry;
|
$registry = $this->registry;
|
||||||
$type = $this;
|
$type = $this;
|
||||||
|
@ -71,7 +72,7 @@ abstract class DoctrineType extends AbstractType
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'em' => null,
|
'em' => null,
|
||||||
'class' => null,
|
'class' => null,
|
||||||
'property' => null,
|
'property' => null,
|
||||||
|
@ -80,7 +81,7 @@ abstract class DoctrineType extends AbstractType
|
||||||
'choices' => null,
|
'choices' => null,
|
||||||
'choice_list' => $choiceList,
|
'choice_list' => $choiceList,
|
||||||
'group_by' => null,
|
'group_by' => null,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelType class.
|
* ModelType class.
|
||||||
|
@ -31,7 +32,7 @@ class ModelType extends AbstractType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$choiceList = function (Options $options) {
|
$choiceList = function (Options $options) {
|
||||||
return new ModelChoiceList(
|
return new ModelChoiceList(
|
||||||
|
@ -43,7 +44,7 @@ class ModelType extends AbstractType
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'template' => 'choice',
|
'template' => 'choice',
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
|
@ -54,7 +55,7 @@ class ModelType extends AbstractType
|
||||||
'choice_list' => $choiceList,
|
'choice_list' => $choiceList,
|
||||||
'group_by' => null,
|
'group_by' => null,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getParent(array $options)
|
public function getParent(array $options)
|
||||||
|
|
|
@ -18,6 +18,7 @@ use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\Form\Event\FilterDataEvent;
|
use Symfony\Component\Form\Event\FilterDataEvent;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form type for use with the Security component's form-based authentication
|
* Form type for use with the Security component's form-based authentication
|
||||||
|
@ -74,17 +75,17 @@ class UserLoginFormType extends AbstractType
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Symfony\Component\Form\AbstractType::getDefaultOptions()
|
* @see Symfony\Component\Form\AbstractType::setDefaultOptions()
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
/* Note: the form's intention must correspond to that for the form login
|
/* Note: the form's intention must correspond to that for the form login
|
||||||
* listener in order for the CSRF token to validate successfully.
|
* listener in order for the CSRF token to validate successfully.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'intention' => 'authenticate',
|
'intention' => 'authenticate',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,11 @@
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
abstract class AbstractType implements FormTypeInterface
|
abstract class AbstractType implements FormTypeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -53,13 +57,32 @@ abstract class AbstractType implements FormTypeInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults($this->getDefaultOptions());
|
||||||
|
$resolver->addAllowedValues($this->getAllowedOptionValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default options for this type.
|
||||||
|
*
|
||||||
|
* @return array The default options
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||||
|
* Use {@link setDefaultOptions()} instead.
|
||||||
|
*/
|
||||||
public function getDefaultOptions()
|
public function getDefaultOptions()
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Returns the allowed option values for each option (if any).
|
||||||
|
*
|
||||||
|
* @return array The allowed option values
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||||
|
* Use {@link setDefaultOptions()} instead.
|
||||||
*/
|
*/
|
||||||
public function getAllowedOptionValues()
|
public function getAllowedOptionValues()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
abstract class AbstractTypeExtension implements FormTypeExtensionInterface
|
abstract class AbstractTypeExtension implements FormTypeExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -37,13 +42,32 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults($this->getDefaultOptions());
|
||||||
|
$resolver->addAllowedValues($this->getAllowedOptionValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides the default options form the extended type.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||||
|
* Use {@link setDefaultOptions()} instead.
|
||||||
|
*/
|
||||||
public function getDefaultOptions()
|
public function getDefaultOptions()
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Returns the allowed option values for each option (if any).
|
||||||
|
*
|
||||||
|
* @return array The allowed option values
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||||
|
* Use {@link setDefaultOptions()} instead.
|
||||||
*/
|
*/
|
||||||
public function getAllowedOptionValues()
|
public function getAllowedOptionValues()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,8 +52,6 @@ CHANGELOG
|
||||||
"single_text" unless "with_seconds" is set to true
|
"single_text" unless "with_seconds" is set to true
|
||||||
* checkboxes of in an expanded multiple-choice field don't include the choice
|
* checkboxes of in an expanded multiple-choice field don't include the choice
|
||||||
in their name anymore. Their names terminate with "[]" now.
|
in their name anymore. Their names terminate with "[]" now.
|
||||||
* [BC BREAK] FormType::getDefaultOptions() and FormType::getAllowedOptionValues()
|
|
||||||
don't receive an options array anymore.
|
|
||||||
* deprecated FormValidatorInterface and substituted its implementations
|
* deprecated FormValidatorInterface and substituted its implementations
|
||||||
by event subscribers
|
by event subscribers
|
||||||
* simplified CSRF protection and removed the csrf type
|
* simplified CSRF protection and removed the csrf type
|
||||||
|
@ -88,3 +86,9 @@ CHANGELOG
|
||||||
* removed superfluous methods from DataMapperInterface
|
* removed superfluous methods from DataMapperInterface
|
||||||
* `mapFormToData`
|
* `mapFormToData`
|
||||||
* `mapDataToForm`
|
* `mapDataToForm`
|
||||||
|
* [BC BREAK] FormType::getDefaultOptions() and FormType::getAllowedOptionValues()
|
||||||
|
don't receive an options array anymore.
|
||||||
|
* added `setDefaultOptions` to FormTypeInterface and FormTypeExtensionInterface
|
||||||
|
which accepts an OptionsResolver instance
|
||||||
|
* deprecated the methods `getDefaultOptions` and `getAllowedOptionValues`
|
||||||
|
in FormTypeInterface and FormTypeExtensionInterface
|
||||||
|
|
|
@ -12,17 +12,18 @@
|
||||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class BirthdayType extends AbstractType
|
class BirthdayType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'years' => range(date('Y') - 120, date('Y')),
|
'years' => range(date('Y') - 120, date('Y')),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class CheckboxType extends AbstractType
|
class CheckboxType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -44,17 +45,17 @@ class CheckboxType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$emptyData = function (FormInterface $form, $clientData) {
|
$emptyData = function (FormInterface $form, $clientData) {
|
||||||
return $clientData;
|
return $clientData;
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'value' => '1',
|
'value' => '1',
|
||||||
'empty_data' => $emptyData,
|
'empty_data' => $emptyData,
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToBooleanArrayTr
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class ChoiceType extends AbstractType
|
class ChoiceType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -143,7 +144,7 @@ class ChoiceType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$choiceList = function (Options $options) {
|
$choiceList = function (Options $options) {
|
||||||
return new SimpleChoiceList(
|
return new SimpleChoiceList(
|
||||||
|
@ -169,7 +170,7 @@ class ChoiceType extends AbstractType
|
||||||
return !$options['expanded'];
|
return !$options['expanded'];
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'choice_list' => $choiceList,
|
'choice_list' => $choiceList,
|
||||||
|
@ -179,7 +180,7 @@ class ChoiceType extends AbstractType
|
||||||
'empty_value' => $emptyValue,
|
'empty_value' => $emptyValue,
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
'single_control' => $singleControl,
|
'single_control' => $singleControl,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
|
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class CollectionType extends AbstractType
|
class CollectionType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -74,16 +75,16 @@ class CollectionType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'allow_add' => false,
|
'allow_add' => false,
|
||||||
'allow_delete' => false,
|
'allow_delete' => false,
|
||||||
'prototype' => true,
|
'prototype' => true,
|
||||||
'prototype_name' => '__name__',
|
'prototype_name' => '__name__',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,17 +13,18 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Locale\Locale;
|
use Symfony\Component\Locale\Locale;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class CountryType extends AbstractType
|
class CountryType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'choices' => Locale::getDisplayCountries(\Locale::getDefault()),
|
'choices' => Locale::getDisplayCountries(\Locale::getDefault()),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransf
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class DateTimeType extends AbstractType
|
class DateTimeType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -129,13 +130,13 @@ class DateTimeType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$singleControl = function (Options $options) {
|
$singleControl = function (Options $options) {
|
||||||
return $options['widget'] === 'single_text';
|
return $options['widget'] === 'single_text';
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'data_timezone' => null,
|
'data_timezone' => null,
|
||||||
'user_timezone' => null,
|
'user_timezone' => null,
|
||||||
|
@ -164,15 +165,9 @@ class DateTimeType extends AbstractType
|
||||||
// this option.
|
// this option.
|
||||||
'data_class' => null,
|
'data_class' => null,
|
||||||
'single_control' => $singleControl,
|
'single_control' => $singleControl,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'input' => array(
|
'input' => array(
|
||||||
'datetime',
|
'datetime',
|
||||||
'string',
|
'string',
|
||||||
|
@ -198,7 +193,7 @@ class DateTimeType extends AbstractType
|
||||||
'text',
|
'text',
|
||||||
'choice',
|
'choice',
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,9 +22,12 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransf
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||||
use Symfony\Component\Form\ReversedTransformer;
|
use Symfony\Component\Form\ReversedTransformer;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class DateType extends AbstractType
|
class DateType extends AbstractType
|
||||||
{
|
{
|
||||||
|
const DEFAULT_FORMAT = \IntlDateFormatter::MEDIUM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +36,7 @@ class DateType extends AbstractType
|
||||||
$format = $options['format'];
|
$format = $options['format'];
|
||||||
$pattern = null;
|
$pattern = null;
|
||||||
|
|
||||||
$allowedFormatOptionValues = array(
|
$allowedFormats = array(
|
||||||
\IntlDateFormatter::FULL,
|
\IntlDateFormatter::FULL,
|
||||||
\IntlDateFormatter::LONG,
|
\IntlDateFormatter::LONG,
|
||||||
\IntlDateFormatter::MEDIUM,
|
\IntlDateFormatter::MEDIUM,
|
||||||
|
@ -41,11 +44,9 @@ class DateType extends AbstractType
|
||||||
);
|
);
|
||||||
|
|
||||||
// If $format is not in the allowed options, it's considered as the pattern of the formatter if it is a string
|
// If $format is not in the allowed options, it's considered as the pattern of the formatter if it is a string
|
||||||
if (!in_array($format, $allowedFormatOptionValues, true)) {
|
if (!in_array($format, $allowedFormats, true)) {
|
||||||
if (is_string($format)) {
|
if (is_string($format)) {
|
||||||
$defaultOptions = $this->getDefaultOptions();
|
$format = self::DEFAULT_FORMAT;
|
||||||
|
|
||||||
$format = $defaultOptions['format'];
|
|
||||||
$pattern = $options['format'];
|
$pattern = $options['format'];
|
||||||
} else {
|
} else {
|
||||||
throw new CreationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom pattern');
|
throw new CreationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom pattern');
|
||||||
|
@ -164,19 +165,19 @@ class DateType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$singleControl = function (Options $options) {
|
$singleControl = function (Options $options) {
|
||||||
return $options['widget'] === 'single_text';
|
return $options['widget'] === 'single_text';
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'years' => range(date('Y') - 5, date('Y') + 5),
|
'years' => range(date('Y') - 5, date('Y') + 5),
|
||||||
'months' => range(1, 12),
|
'months' => range(1, 12),
|
||||||
'days' => range(1, 31),
|
'days' => range(1, 31),
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => self::DEFAULT_FORMAT,
|
||||||
'data_timezone' => null,
|
'data_timezone' => null,
|
||||||
'user_timezone' => null,
|
'user_timezone' => null,
|
||||||
'empty_value' => null,
|
'empty_value' => null,
|
||||||
|
@ -189,16 +190,10 @@ class DateType extends AbstractType
|
||||||
// representation is not \DateTime, but an array, we need to unset
|
// representation is not \DateTime, but an array, we need to unset
|
||||||
// this option.
|
// this option.
|
||||||
'data_class' => null,
|
'data_class' => null,
|
||||||
'single_control' => $singleControl,
|
'single_control' => $singleControl,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'input' => array(
|
'input' => array(
|
||||||
'datetime',
|
'datetime',
|
||||||
'string',
|
'string',
|
||||||
|
@ -210,7 +205,7 @@ class DateType extends AbstractType
|
||||||
'text',
|
'text',
|
||||||
'choice',
|
'choice',
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class FileType extends AbstractType
|
class FileType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -41,11 +42,11 @@ class FileType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,7 @@ use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
use Symfony\Component\Form\Exception\FormException;
|
use Symfony\Component\Form\Exception\FormException;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class FormType extends AbstractType
|
class FormType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -147,7 +148,7 @@ class FormType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
// Derive "data_class" option from passed "data" object
|
// Derive "data_class" option from passed "data" object
|
||||||
$dataClass = function (Options $options) {
|
$dataClass = function (Options $options) {
|
||||||
|
@ -192,7 +193,7 @@ class FormType extends AbstractType
|
||||||
return false !== $options['property_path'];
|
return false !== $options['property_path'];
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'data' => null,
|
'data' => null,
|
||||||
'data_class' => $dataClass,
|
'data_class' => $dataClass,
|
||||||
'empty_data' => $emptyData,
|
'empty_data' => $emptyData,
|
||||||
|
@ -212,7 +213,7 @@ class FormType extends AbstractType
|
||||||
'virtual' => false,
|
'virtual' => false,
|
||||||
'single_control' => false,
|
'single_control' => false,
|
||||||
'translation_domain' => 'messages',
|
'translation_domain' => 'messages',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,21 +12,22 @@
|
||||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class HiddenType extends AbstractType
|
class HiddenType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
// hidden fields cannot have a required attribute
|
// hidden fields cannot have a required attribute
|
||||||
'required' => false,
|
'required' => false,
|
||||||
// Pass errors to the parent
|
// Pass errors to the parent
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class IntegerType extends AbstractType
|
class IntegerType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -33,24 +34,18 @@ class IntegerType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
// default precision is locale specific (usually around 3)
|
// default precision is locale specific (usually around 3)
|
||||||
'precision' => null,
|
'precision' => null,
|
||||||
'grouping' => false,
|
'grouping' => false,
|
||||||
// Integer cast rounds towards 0, so do the same when displaying fractions
|
// Integer cast rounds towards 0, so do the same when displaying fractions
|
||||||
'rounding_mode' => \NumberFormatter::ROUND_DOWN,
|
'rounding_mode' => \NumberFormatter::ROUND_DOWN,
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'rounding_mode' => array(
|
'rounding_mode' => array(
|
||||||
\NumberFormatter::ROUND_FLOOR,
|
\NumberFormatter::ROUND_FLOOR,
|
||||||
\NumberFormatter::ROUND_DOWN,
|
\NumberFormatter::ROUND_DOWN,
|
||||||
|
@ -60,7 +55,7 @@ class IntegerType extends AbstractType
|
||||||
\NumberFormatter::ROUND_UP,
|
\NumberFormatter::ROUND_UP,
|
||||||
\NumberFormatter::ROUND_CEILING,
|
\NumberFormatter::ROUND_CEILING,
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,17 +13,18 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Locale\Locale;
|
use Symfony\Component\Locale\Locale;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class LanguageType extends AbstractType
|
class LanguageType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'choices' => Locale::getDisplayLanguages(\Locale::getDefault()),
|
'choices' => Locale::getDisplayLanguages(\Locale::getDefault()),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,17 +13,18 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Locale\Locale;
|
use Symfony\Component\Locale\Locale;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class LocaleType extends AbstractType
|
class LocaleType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'choices' => Locale::getDisplayLocales(\Locale::getDefault()),
|
'choices' => Locale::getDisplayLocales(\Locale::getDefault()),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class MoneyType extends AbstractType
|
class MoneyType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -48,15 +49,15 @@ class MoneyType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'precision' => 2,
|
'precision' => 2,
|
||||||
'grouping' => false,
|
'grouping' => false,
|
||||||
'divisor' => 1,
|
'divisor' => 1,
|
||||||
'currency' => 'EUR',
|
'currency' => 'EUR',
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class NumberType extends AbstractType
|
class NumberType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -32,23 +33,17 @@ class NumberType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
// default precision is locale specific (usually around 3)
|
// default precision is locale specific (usually around 3)
|
||||||
'precision' => null,
|
'precision' => null,
|
||||||
'grouping' => false,
|
'grouping' => false,
|
||||||
'rounding_mode' => \NumberFormatter::ROUND_HALFUP,
|
'rounding_mode' => \NumberFormatter::ROUND_HALFUP,
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'rounding_mode' => array(
|
'rounding_mode' => array(
|
||||||
\NumberFormatter::ROUND_FLOOR,
|
\NumberFormatter::ROUND_FLOOR,
|
||||||
\NumberFormatter::ROUND_DOWN,
|
\NumberFormatter::ROUND_DOWN,
|
||||||
|
@ -58,7 +53,7 @@ class NumberType extends AbstractType
|
||||||
\NumberFormatter::ROUND_UP,
|
\NumberFormatter::ROUND_UP,
|
||||||
\NumberFormatter::ROUND_CEILING,
|
\NumberFormatter::ROUND_CEILING,
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class PasswordType extends AbstractType
|
class PasswordType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -39,11 +40,11 @@ class PasswordType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'always_empty' => true,
|
'always_empty' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class PercentType extends AbstractType
|
class PercentType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -28,26 +29,20 @@ class PercentType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'precision' => 0,
|
'precision' => 0,
|
||||||
'type' => 'fractional',
|
'type' => 'fractional',
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'type' => array(
|
'type' => array(
|
||||||
'fractional',
|
'fractional',
|
||||||
'integer',
|
'integer',
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class RepeatedType extends AbstractType
|
class RepeatedType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -40,9 +41,9 @@ class RepeatedType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
'first_options' => array(),
|
'first_options' => array(),
|
||||||
|
@ -50,7 +51,7 @@ class RepeatedType extends AbstractType
|
||||||
'first_name' => 'first',
|
'first_name' => 'first',
|
||||||
'second_name' => 'second',
|
'second_name' => 'second',
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToStringTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToStringTransformer;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class TextType extends AbstractType
|
class TextType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -30,11 +31,11 @@ class TextType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'single_control' => true,
|
'single_control' => true,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class TimeType extends AbstractType
|
class TimeType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -138,13 +139,13 @@ class TimeType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$singleControl = function (Options $options) {
|
$singleControl = function (Options $options) {
|
||||||
return $options['widget'] === 'single_text';
|
return $options['widget'] === 'single_text';
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'hours' => range(0, 23),
|
'hours' => range(0, 23),
|
||||||
'minutes' => range(0, 59),
|
'minutes' => range(0, 59),
|
||||||
'seconds' => range(0, 59),
|
'seconds' => range(0, 59),
|
||||||
|
@ -164,15 +165,9 @@ class TimeType extends AbstractType
|
||||||
// this option.
|
// this option.
|
||||||
'data_class' => null,
|
'data_class' => null,
|
||||||
'single_control' => $singleControl,
|
'single_control' => $singleControl,
|
||||||
);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$resolver->setAllowedValues(array(
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getAllowedOptionValues()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'input' => array(
|
'input' => array(
|
||||||
'datetime',
|
'datetime',
|
||||||
'string',
|
'string',
|
||||||
|
@ -184,7 +179,7 @@ class TimeType extends AbstractType
|
||||||
'text',
|
'text',
|
||||||
'choice',
|
'choice',
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
namespace Symfony\Component\Form\Extension\Core\Type;
|
namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class TimezoneType extends AbstractType
|
class TimezoneType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -24,11 +25,11 @@ class TimezoneType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'choices' => self::getTimezones(),
|
'choices' => self::getTimezones(),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
|
use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class UrlType extends AbstractType
|
class UrlType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -28,11 +29,11 @@ class UrlType extends AbstractType
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'default_protocol' => 'http',
|
'default_protocol' => 'http',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
@ -81,14 +82,14 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'csrf_protection' => $this->defaultEnabled,
|
'csrf_protection' => $this->defaultEnabled,
|
||||||
'csrf_field_name' => $this->defaultFieldName,
|
'csrf_field_name' => $this->defaultFieldName,
|
||||||
'csrf_provider' => $this->defaultCsrfProvider,
|
'csrf_provider' => $this->defaultCsrfProvider,
|
||||||
'intention' => 'unknown',
|
'intention' => 'unknown',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
|
||||||
use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener;
|
use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener;
|
||||||
use Symfony\Component\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\ValidatorInterface;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
@ -72,14 +73,14 @@ class FormTypeValidatorExtension extends AbstractTypeExtension
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
// BC clause
|
// BC clause
|
||||||
$constraints = function (Options $options) {
|
$constraints = function (Options $options) {
|
||||||
return $options['validation_constraint'];
|
return $options['validation_constraint'];
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'error_mapping' => array(),
|
'error_mapping' => array(),
|
||||||
'validation_groups' => null,
|
'validation_groups' => null,
|
||||||
// "validation_constraint" is deprecated. Use "constraints".
|
// "validation_constraint" is deprecated. Use "constraints".
|
||||||
|
@ -89,7 +90,7 @@ class FormTypeValidatorExtension extends AbstractTypeExtension
|
||||||
'invalid_message' => 'This value is not valid.',
|
'invalid_message' => 'This value is not valid.',
|
||||||
'extra_fields_message' => 'This form should not contain extra fields.',
|
'extra_fields_message' => 'This form should not contain extra fields.',
|
||||||
'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
|
'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Extension\Validator\Type;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractTypeExtension;
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
@ -22,16 +23,16 @@ class RepeatedTypeValidatorExtension extends AbstractTypeExtension
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
// Map errors to the first field
|
// Map errors to the first field
|
||||||
$errorMapping = function (Options $options) {
|
$errorMapping = function (Options $options) {
|
||||||
return array('.' => $options['first_name']);
|
return array('.' => $options['first_name']);
|
||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'error_mapping' => $errorMapping,
|
'error_mapping' => $errorMapping,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,16 +185,12 @@ class FormFactory implements FormFactoryInterface
|
||||||
// Merge the default options of all types to an array of default
|
// Merge the default options of all types to an array of default
|
||||||
// options. Default options of children override default options
|
// options. Default options of children override default options
|
||||||
// of parents.
|
// of parents.
|
||||||
$typeOptions = $type->getDefaultOptions();
|
/* @var FormTypeInterface $type */
|
||||||
$optionsResolver->setDefaults($typeOptions);
|
$type->setDefaultOptions($optionsResolver);
|
||||||
$optionsResolver->addAllowedValues($type->getAllowedOptionValues());
|
|
||||||
$knownOptions = array_merge($knownOptions, array_keys($typeOptions));
|
|
||||||
|
|
||||||
foreach ($type->getExtensions() as $typeExtension) {
|
foreach ($type->getExtensions() as $typeExtension) {
|
||||||
$extensionOptions = $typeExtension->getDefaultOptions();
|
/* @var FormTypeExtensionInterface $typeExtension */
|
||||||
$optionsResolver->setDefaults($extensionOptions);
|
$typeExtension->setDefaultOptions($optionsResolver);
|
||||||
$optionsResolver->addAllowedValues($typeExtension->getAllowedOptionValues());
|
|
||||||
$knownOptions = array_merge($knownOptions, array_keys($extensionOptions));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +198,13 @@ class FormFactory implements FormFactoryInterface
|
||||||
$type = end($types);
|
$type = end($types);
|
||||||
|
|
||||||
// Validate options required by the factory
|
// Validate options required by the factory
|
||||||
$diff = array_diff(self::$requiredOptions, $knownOptions);
|
$diff = array();
|
||||||
|
|
||||||
|
foreach (self::$requiredOptions as $requiredOption) {
|
||||||
|
if (!$optionsResolver->isKnown($requiredOption)) {
|
||||||
|
$diff[] = $requiredOption;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count($diff) > 0) {
|
if (count($diff) > 0) {
|
||||||
throw new TypeDefinitionException(sprintf('Type "%s" should support the option(s) "%s"', $type->getName(), implode('", "', $diff)));
|
throw new TypeDefinitionException(sprintf('Type "%s" should support the option(s) "%s"', $type->getName(), implode('", "', $diff)));
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
interface FormTypeExtensionInterface
|
interface FormTypeExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -53,19 +58,11 @@ interface FormTypeExtensionInterface
|
||||||
function buildViewBottomUp(FormView $view, FormInterface $form);
|
function buildViewBottomUp(FormView $view, FormInterface $form);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides the default options form the extended type.
|
* Overrides the default options from the extended type.
|
||||||
*
|
*
|
||||||
* @return array
|
* @param OptionsResolver $resolver The resolver for the options.
|
||||||
*/
|
*/
|
||||||
function getDefaultOptions();
|
function setDefaultOptions(OptionsResolver $resolver);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the allowed option values for each option (if any).
|
|
||||||
*
|
|
||||||
* @return array The allowed option values
|
|
||||||
*/
|
|
||||||
function getAllowedOptionValues();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the type being extended.
|
* Returns the name of the type being extended.
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
namespace Symfony\Component\Form;
|
namespace Symfony\Component\Form;
|
||||||
|
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
interface FormTypeInterface
|
interface FormTypeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -73,18 +78,11 @@ interface FormTypeInterface
|
||||||
function createBuilder($name, FormFactoryInterface $factory, array $options);
|
function createBuilder($name, FormFactoryInterface $factory, array $options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default options for this type.
|
* Sets the default options for this type.
|
||||||
*
|
*
|
||||||
* @return array The default options
|
* @param OptionsResolver $resolver The resolver for the options.
|
||||||
*/
|
*/
|
||||||
function getDefaultOptions();
|
function setDefaultOptions(OptionsResolver $resolver);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the allowed option values for each option (if any).
|
|
||||||
*
|
|
||||||
* @return array The allowed option values
|
|
||||||
*/
|
|
||||||
function getAllowedOptionValues();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the parent type.
|
* Returns the name of the parent type.
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Symfony\Component\Form\Tests\Fixtures;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilder;
|
use Symfony\Component\Form\FormBuilder;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class AuthorType extends AbstractType
|
class AuthorType extends AbstractType
|
||||||
{
|
{
|
||||||
|
@ -20,10 +21,10 @@ class AuthorType extends AbstractType
|
||||||
return 'author';
|
return 'author';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultOptions()
|
public function setDefaultOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
return array(
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,15 +178,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getExtensions')
|
->method('getExtensions')
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getAllowedOptionValues')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getDefaultOptions')
|
|
||||||
->will($this->returnValue(array(
|
|
||||||
'required' => false,
|
|
||||||
'max_length' => null,
|
|
||||||
)));
|
|
||||||
|
|
||||||
$this->extension1->addType($type);
|
$this->extension1->addType($type);
|
||||||
|
|
||||||
|
@ -205,15 +196,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getExtensions')
|
->method('getExtensions')
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getAllowedOptionValues')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getDefaultOptions')
|
|
||||||
->will($this->returnValue(array(
|
|
||||||
'data' => null,
|
|
||||||
'max_length' => null,
|
|
||||||
)));
|
|
||||||
|
|
||||||
$this->extension1->addType($type);
|
$this->extension1->addType($type);
|
||||||
|
|
||||||
|
@ -232,15 +214,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getExtensions')
|
->method('getExtensions')
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getAllowedOptionValues')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getDefaultOptions')
|
|
||||||
->will($this->returnValue(array(
|
|
||||||
'data' => null,
|
|
||||||
'required' => false,
|
|
||||||
)));
|
|
||||||
|
|
||||||
$this->extension1->addType($type);
|
$this->extension1->addType($type);
|
||||||
|
|
||||||
|
@ -259,16 +232,6 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('getExtensions')
|
->method('getExtensions')
|
||||||
->will($this->returnValue(array()));
|
->will($this->returnValue(array()));
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getAllowedOptionValues')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
$type->expects($this->any())
|
|
||||||
->method('getDefaultOptions')
|
|
||||||
->will($this->returnValue(array(
|
|
||||||
'data' => null,
|
|
||||||
'required' => false,
|
|
||||||
'max_length' => null,
|
|
||||||
)));
|
|
||||||
$type->expects($this->any())
|
$type->expects($this->any())
|
||||||
->method('createBuilder')
|
->method('createBuilder')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
|
Reference in New Issue