Skip to content

Commit

Permalink
[US-2108] Fix additional deprecations in forms to allow update to Sym…
Browse files Browse the repository at this point in the history
…fony 3
  • Loading branch information
PetrHeinz committed Mar 23, 2017
2 parents 89b236c + b4badd4 commit 8400ca3
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 32 deletions.
Expand Up @@ -88,7 +88,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'main_constraints' => [
new Constraints\NotBlank(['message' => 'Please enter name']),
],
'options' => [
'entry_options' => [
'required' => false,
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -83,7 +83,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$builder
->add('orderNumber', TextType::class, ['read_only' => true])
->add('orderNumber', TextType::class, [
'attr' => ['readonly' => true],
])
->add('status', ChoiceType::class, [
'required' => true,
'choices' => $this->orderStatusFacade->getAll(),
Expand Down
Expand Up @@ -19,7 +19,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', LocalizedType::class, [
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter all country names']),
new Constraints\Length(['max' => 255, 'maxMessage' => 'Status name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'main_constraints' => [
new Constraints\NotBlank(['message' => 'Please enter name']),
],
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Name cannot be longer than {{ limit }} characters']),
],
Expand Down
Expand Up @@ -65,7 +65,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('exchangeRate', NumberType::class, [
'required' => true,
'scale' => 6,
'read_only' => $options['is_default_currency'],
'attr' => [
'readonly' => $options['is_default_currency'],
],
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter currency exchange rate']),
new Constraints\GreaterThan(0),
Expand Down
Expand Up @@ -43,7 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('domainDefaultCurrencies', CollectionType::class, [
'required' => true,
'entry_type' => ChoiceType::class,
'options' => [
'entry_options' => [
'required' => true,
'choices' => $this->currencyFacade->getAll(),
'choice_label' => 'name',
Expand Down
Expand Up @@ -21,7 +21,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('name', LocalizedType::class, [
'required' => true,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter availability name in all languages']),
new Constraints\Length(['max' => 100, 'maxMessage' => 'Availability name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -22,7 +22,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('name', LocalizedType::class, [
'required' => true,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter flag name in all languages']),
new Constraints\Length(['max' => 100, 'maxMessage' => 'Flag name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -21,7 +21,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('name', LocalizedType::class, [
'required' => false,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter parameter name']),
new Constraints\Length(['max' => 100, 'maxMessage' => 'Parameter name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -45,7 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'main_constraints' => [
new Constraints\NotBlank(['message' => 'Please enter parameter value']),
],
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Name cannot be longer than {{ limit }} characters']),
],
Expand Down
Expand Up @@ -197,7 +197,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('heurekaCpcValues', MultidomainType::class, [
'entry_type' => MoneyType::class,
'required' => false,
'options' => [
'entry_options' => [
'currency' => 'CZK',
'scale' => 2,
'constraints' => [
Expand All @@ -215,7 +215,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('zboziCpcValues', MultidomainType::class, [
'entry_type' => MoneyType::class,
'required' => false,
'options' => [
'entry_options' => [
'currency' => 'CZK',
'scale' => 2,
'constraints' => [
Expand All @@ -229,7 +229,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('zboziCpcSearchValues', MultidomainType::class, [
'entry_type' => MoneyType::class,
'required' => false,
'options' => [
'entry_options' => [
'currency' => 'CZK',
'scale' => 2,
'constraints' => [
Expand Down
Expand Up @@ -91,7 +91,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
if ($options['product'] !== null && $options['product']->isVariant()) {
$builder->add('variantAlias', LocalizedType::class, [
'required' => false,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Variant alias cannot be longer then {{ limit }} characters']),
],
Expand All @@ -102,7 +102,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('name', LocalizedType::class, [
'required' => false,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Product name cannot be longer than {{ limit }} characters']),
],
Expand Down
Expand Up @@ -20,7 +20,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('name', LocalizedType::class, [
'required' => true,
'options' => [
'entry_options' => [
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter unit name in all languages']),
new Constraints\Length(['max' => 10, 'maxMessage' => 'Unit name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -40,7 +40,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'main_constraints' => [
new Constraints\NotBlank(['message' => 'Please enter name']),
],
'options' => [
'entry_options' => [
'required' => false,
'constraints' => [
new Constraints\Length(['max' => 255, 'maxMessage' => 'Name cannot be longer than {{ limit }} characters']),
Expand Down
Expand Up @@ -33,7 +33,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => false,
'scale' => 4,
'disabled' => $options['scenario'] === self::SCENARIO_EDIT,
'read_only' => $options['scenario'] === self::SCENARIO_EDIT,
'attr' => [
'readonly' => $options['scenario'] === self::SCENARIO_EDIT,
],
'invalid_message' => 'Please enter VAT in correct format.',
'constraints' => [
new Constraints\NotBlank(['message' => 'Please enter VAT rate']),
Expand Down
Expand Up @@ -24,7 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$resizeListener = new ResizeFormListener(
$options['entry_type'],
$options['options'],
$options['entry_options'],
$options['allow_add'],
$options['allow_delete'],
$options['delete_empty']
Expand Down
Expand Up @@ -36,7 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
])
->add('email', EmailType::class, [
'read_only' => true,
'attr' => ['readonly' => true],
'required' => false,
])
->add('password', RepeatedType::class, [
Expand All @@ -49,7 +49,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'constraints' => [
new Constraints\Length(['min' => 6, 'minMessage' => 'Password cannot be longer then {{ limit }} characters']),
],
'attr' => ['autocomplete' => 'off'],
],
'invalid_message' => 'Passwords do not match',
]);
Expand Down
Expand Up @@ -30,11 +30,11 @@ public function __construct(Localization $localization)
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
Utils::setArrayDefaultValue($options['options'], 'required', $options['required']);
Utils::setArrayDefaultValue($options['options'], 'constraints', []);
Utils::setArrayDefaultValue($options['entry_options'], 'required', $options['required']);
Utils::setArrayDefaultValue($options['entry_options'], 'constraints', []);

$defaultLocaleOptions = $options['options'];
$otherLocaleOptions = $options['options'];
$defaultLocaleOptions = $options['entry_options'];
$otherLocaleOptions = $options['entry_options'];

$defaultLocaleOptions['constraints'] = array_merge(
$defaultLocaleOptions['constraints'],
Expand All @@ -60,9 +60,9 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'compound' => true,
'options' => [],
'main_constraints' => [],
'entry_type' => TextType::class,
'entry_options' => [],
'main_constraints' => [],
]);
}
}
10 changes: 5 additions & 5 deletions project-base/src/Shopsys/ShopBundle/Form/MultidomainType.php
Expand Up @@ -32,10 +32,10 @@ public function __construct(Domain $domain)
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
Utils::setArrayDefaultValue($options['options'], 'required', $options['required']);
Utils::setArrayDefaultValue($options['options'], 'constraints', []);
Utils::setArrayDefaultValue($options['entry_options'], 'required', $options['required']);
Utils::setArrayDefaultValue($options['entry_options'], 'constraints', []);

$subOptions = $options['options'];
$subOptions = $options['entry_options'];
$subOptions['required'] = $options['required'] && $subOptions['required'];

foreach ($this->domain->getAll() as $domainConfig) {
Expand All @@ -56,9 +56,9 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'compound' => true,
'options' => [],
'optionsByDomainId' => [],
'entry_type' => TextType::class,
'entry_options' => [],
'optionsByDomainId' => [],
]);
}

Expand Down

0 comments on commit 8400ca3

Please sign in to comment.