Skip to content

Commit

Permalink
Merge pull request #5670 from spryker/feature/te-3787/master/update-s…
Browse files Browse the repository at this point in the history
…ymfony-form

te-3787 Update Symfony Form
  • Loading branch information
demkos committed Jul 11, 2019
2 parents 8c5b6b4 + f21c0c9 commit da4ad3f
Show file tree
Hide file tree
Showing 66 changed files with 29 additions and 123 deletions.
1 change: 0 additions & 1 deletion Bundles/Acl/phpstan.neon
@@ -1,4 +1,3 @@
parameters:
ignoreErrors:
- '#.+ has invalid typehint type Symfony\\Component\\OptionsResolver\\OptionsResolverInterface.#'
- '#Argument of an invalid type .+RolesTransfer supplied for foreach, only iterables are supported.#'
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\NotBlank;
Expand Down Expand Up @@ -62,11 +61,11 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @deprecated Use `configureOptions()` instead.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*
* @return void
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function setDefaultOptions(OptionsResolver $resolver)
{
$this->configureOptions($resolver);
}
Expand Down
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
Expand Down Expand Up @@ -45,11 +44,11 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @deprecated Use `configureOptions()` instead.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*
* @return void
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function setDefaultOptions(OptionsResolver $resolver)
{
$this->configureOptions($resolver);
}
Expand Down
Expand Up @@ -70,7 +70,6 @@ protected function addCompanyBusinessUnitCollectionField(FormBuilderInterface $b
'label' => 'Business Unit',
'placeholder' => 'Business Unit name',
'choices' => $options[static::OPTION_COMPANY_BUSINESS_UNIT_CHOICES],
'choices_as_values' => true,
'required' => true,
]);

Expand Down
Expand Up @@ -188,7 +188,6 @@ protected function addParentNodeField(FormBuilderInterface $builder, array $choi
'property_path' => 'parentCategoryNode',
'label' => 'Parent',
'choices' => $choices,
'choices_as_values' => true,
'choice_label' => 'name',
'choice_value' => 'idCategoryNode',
'group_by' => 'path',
Expand All @@ -209,7 +208,6 @@ protected function addExtraParentsField(FormBuilderInterface $builder, array $ch
$builder->add(self::FIELD_EXTRA_PARENTS, Select2ComboBoxType::class, [
'label' => 'Additional Parents',
'choices' => $choices,
'choices_as_values' => true,
'choice_label' => 'name',
'choice_value' => 'idCategoryNode',
'multiple' => true,
Expand Down Expand Up @@ -240,7 +238,6 @@ protected function addTemplateField(FormBuilderInterface $builder, array $choice
$builder->add(static::FIELD_TEMPLATE, Select2ComboBoxType::class, [
'label' => 'Template',
'choices' => array_flip($choices),
'choices_as_values' => true,
'required' => true,
'constraints' => [
new NotBlank(),
Expand Down
Expand Up @@ -304,7 +304,7 @@ protected function extractGlossaryMapping(?int $idPage, LocaleTransfer $localeTr
*/
protected function handleAjaxRequest(array $forms, int $idForm, LocaleTransfer $localeTransfer): JsonResponse
{
if ($forms[$idForm]->isValid()) {
if ($forms[$idForm]->isSubmitted() && $forms[$idForm]->isValid()) {
$data = $forms[$idForm]->getData();
$this->saveGlossaryKeyPageMapping($data, $localeTransfer);

Expand Down
Expand Up @@ -88,7 +88,6 @@ protected function addCmsBlockFields(FormBuilderInterface $builder, array $posit
'property_path' => static::FIELD_CMS_BLOCKS . '[' . $idCmsBlockCategoryPosition . ']',
'label' => 'CMS Blocks: ' . $positionName,
'choices' => array_flip($choices),
'choices_as_values' => true,
'multiple' => true,
'required' => false,
'attr' => [
Expand Down
Expand Up @@ -144,7 +144,6 @@ protected function addCategoryField(FormBuilderInterface $builder, array $catego
'property_path' => static::FIELD_CATEGORIES . '[' . $idCmsBlockCategoryPosition . ']',
'label' => 'Categories: ' . $positionName,
'choices' => array_flip($categoryList),
'choices_as_values' => true,
'multiple' => true,
'required' => false,
]);
Expand Down
Expand Up @@ -129,7 +129,6 @@ protected function addFkTemplateField(FormBuilderInterface $builder, array $choi
$builder->add(static::FIELD_FK_TEMPLATE, ChoiceType::class, [
'label' => 'Template',
'choices' => array_flip($choices[static::OPTION_TEMPLATE_CHOICES]),
'choices_as_values' => true,
'constraints' => [
new Callback([
'callback' => function ($name, ExecutionContextInterface $context) {
Expand Down
Expand Up @@ -112,7 +112,6 @@ protected function addFkTemplateField(FormBuilderInterface $builder, array $choi
$builder->add(static::FIELD_FK_TEMPLATE, ChoiceType::class, [
'label' => 'Template',
'choices' => array_flip($choices),
'choices_as_values' => true,
]);

return $this;
Expand Down
Expand Up @@ -61,7 +61,6 @@ protected function addVersionNameField(FormBuilderInterface $builder, array $cho
$builder->add('version', ChoiceType::class, [
'label' => false,
'choices' => array_flip($choices),
'choices_as_values' => true,
'required' => true,
'constraints' => [
new Required(),
Expand Down
Expand Up @@ -105,7 +105,6 @@ protected function addParentNameField(
'label' => 'Parent',
'placeholder' => 'No parent',
'choices' => $choicesValues,
'choices_as_values' => true,
'required' => false,
'choice_attr' => $choicesAttributes,
]);
Expand Down Expand Up @@ -178,7 +177,6 @@ protected function addCompanyField(FormBuilderInterface $builder, array $choices
'label' => 'Company',
'placeholder' => 'Select one',
'choices' => $choices,
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down
Expand Up @@ -63,7 +63,6 @@ protected function addCompanyBusinessUnitCollectionField(FormBuilderInterface $b
'placeholder' => 'Business Unit name',
'choices' => $options[static::OPTION_VALUES_BUSINESS_UNITS_CHOICES],
'choice_attr' => $options[static::OPTION_ATTRIBUTES_BUSINESS_UNITS_CHOICES],
'choices_as_values' => true,
'required' => true,
'attr' => [
'template_path' => $this->getTemplatePath(),
Expand Down
Expand Up @@ -165,7 +165,6 @@ protected function addPermissionCollectionField(FormBuilderInterface $builder, a
{
$builder->add(static::FIELD_PERMISSION_COLLECTION, ChoiceType::class, [
'choices' => $options[static::OPTION_PERMISSION_CHOICES],
'choices_as_values' => true,
'label' => false,
'expanded' => true,
'required' => true,
Expand Down
Expand Up @@ -72,7 +72,6 @@ protected function addCompanyRoleCollectionField(FormBuilderInterface $builder,
$builder->add(static::FIELD_COMPANY_ROLE_COLLECTION, ChoiceType::class, [
'choices' => $options[static::OPTION_COMPANY_ROLE_CHOICES],
'constraints' => $this->createCompanyRoleCollectionConstraints(),
'choices_as_values' => true,
'label' => false,
'expanded' => true,
'required' => true,
Expand Down
Expand Up @@ -75,7 +75,6 @@ protected function addCompanyRoleCollectionField(FormBuilderInterface $builder,
'choices' => $options[static::OPTION_VALUES_ROLES_CHOICES],
'choice_attr' => $options[static::OPTION_ATTRIBUTES_ROLES_CHOICES],
'constraints' => $this->createCompanyRoleCollectionConstraints(),
'choices_as_values' => true,
'label' => false,
'expanded' => true,
'required' => true,
Expand Down
Expand Up @@ -90,7 +90,6 @@ protected function addCompanyField(FormBuilderInterface $builder, array $choices
'label' => 'Company',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand All @@ -111,7 +110,6 @@ protected function addCountryField(FormBuilderInterface $builder, array $choices
'label' => 'Country',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down
Expand Up @@ -125,7 +125,6 @@ protected function addSalutationField(FormBuilderInterface $builder, array $choi
'label' => 'Salutation',
'placeholder' => 'Select one',
'choices' => $choices,
'choices_as_values' => true,
'required' => false,
]);

Expand Down Expand Up @@ -174,7 +173,6 @@ protected function addGenderField(FormBuilderInterface $builder, array $choices)
'label' => 'Gender',
'placeholder' => 'Select one',
'choices' => $choices,
'choices_as_values' => true,
'constraints' => [
new Required(),
],
Expand Down
Expand Up @@ -111,7 +111,6 @@ protected function addCompanyField(FormBuilderInterface $builder, array $choices
'label' => 'Company',
'placeholder' => 'Company name',
'choices' => $choices,
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down
Expand Up @@ -70,7 +70,6 @@ protected function addCompanyField(FormBuilderInterface $builder, array $choices
'label' => 'Company',
'placeholder' => 'Company name',
'choices' => $choices,
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
new GreaterThan([
Expand Down
Expand Up @@ -124,7 +124,6 @@ protected function addSalutationField(FormBuilderInterface $builder, array $choi
'label' => 'Salutation',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
]);

return $this;
Expand Down Expand Up @@ -261,7 +260,6 @@ protected function addFkCountryField(FormBuilderInterface $builder, array $choic
'label' => 'Country',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'preferred_choices' => $preferredChoices,
'constraints' => [
new NotBlank(),
Expand Down
Expand Up @@ -131,7 +131,6 @@ protected function addSalutationField(FormBuilderInterface $builder, array $choi
'label' => 'Salutation',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down Expand Up @@ -182,7 +181,6 @@ protected function addGenderField(FormBuilderInterface $builder, array $choices)
'label' => 'Gender',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'constraints' => [
new Required(),
],
Expand Down Expand Up @@ -259,7 +257,6 @@ protected function addLocaleField(FormBuilderInterface $builder, array $choices)
'label' => 'Locale',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'required' => false,

]);
Expand Down
Expand Up @@ -79,7 +79,6 @@ protected function addDefaultBillingAddressField(FormBuilderInterface $builder,
'label' => 'Billing Address',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'required' => false,
]);

Expand All @@ -98,7 +97,6 @@ protected function addDefaultShippingAddressField(FormBuilderInterface $builder,
'label' => 'Shipping Address',
'placeholder' => 'Select one',
'choices' => array_flip($choices),
'choices_as_values' => true,
'required' => false,
]);

Expand Down
Expand Up @@ -47,7 +47,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'expanded' => true,
'multiple' => true,
'choices' => array_flip($options[static::BUNDLE_NAME_CHOICES]),
'choices_as_values' => true,
]);

$builder->add(static::SHOW_INCOMING, CheckboxType::class, [
Expand Down
Expand Up @@ -197,7 +197,6 @@ protected function addDiscountCollectorStrategyTypeSelector(FormBuilderInterface
'multiple' => false,
'label' => 'Discount collection type',
'choices' => array_flip($this->getFactory()->createCalculatorFormDataProvider()->getOptions()[static::OPTION_COLLECTOR_TYPE_CHOICES]),
'choices_as_values' => true,
'attr' => [
'class' => 'inline-radio',
],
Expand All @@ -217,7 +216,6 @@ protected function addCalculatorType(FormBuilderInterface $builder)
'label' => 'Calculator type',
'placeholder' => 'Select one',
'choices' => array_flip($this->getFactory()->createCalculatorFormDataProvider()->getData()[static::FIELD_CALCULATOR_PLUGIN]),
'choices_as_values' => true,
'required' => true,
'choice_attr' => function ($pluginName) {
return [
Expand Down
Expand Up @@ -90,7 +90,6 @@ protected function addDiscountType(FormBuilderInterface $builder)
$builder->add(static::FIELD_DISCOUNT_TYPE, ChoiceType::class, [
'label' => 'Discount Type',
'choices' => array_flip($this->getVoucherChoices()),
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down Expand Up @@ -163,7 +162,6 @@ protected function addExclusive(FormBuilderInterface $builder)
self::NON_EXCLUSIVE,
self::EXCLUSIVE,
]),
'choices_as_values' => true,
'constraints' => [
new NotBlank(),
],
Expand Down
Expand Up @@ -96,7 +96,6 @@ protected function addRandomGeneratedCodeLength(FormBuilderInterface $builder)
'placeholder' => 'No additional random characters',
'required' => false,
'choices' => array_flip($this->createCodeLengthRangeList()),
'choices_as_values' => true,
]
);

Expand Down
1 change: 0 additions & 1 deletion Bundles/DummyPayment/phpstan.neon
@@ -1,3 +1,2 @@
parameters:
ignoreErrors:
- '#.+ has invalid typehint type Symfony\\Component\\OptionsResolver\\OptionsResolverInterface.#'
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class CreditCardSubForm extends AbstractSubForm
{
Expand Down Expand Up @@ -68,11 +67,11 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @deprecated Use `configureOptions()` instead.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*
* @return void
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function setDefaultOptions(OptionsResolver $resolver)
{
$this->configureOptions($resolver);
}
Expand Down Expand Up @@ -177,7 +176,6 @@ protected function addCardExpiresMonth(FormBuilderInterface $builder, array $opt
[
'label' => 'dummyPaymentCreditCard.card_expires',
'choices' => array_flip($options[self::OPTIONS_FIELD_NAME][self::OPTION_CARD_EXPIRES_CHOICES_MONTH]),
'choices_as_values' => true,
'required' => true,
'constraints' => [
$this->createNotBlankConstraint(),
Expand All @@ -202,7 +200,6 @@ protected function addCardExpiresYear(FormBuilderInterface $builder, array $opti
[
'label' => false,
'choices' => array_flip($options[self::OPTIONS_FIELD_NAME][self::OPTION_CARD_EXPIRES_CHOICES_YEAR]),
'choices_as_values' => true,
'required' => true,
'attr' => [
'placeholder' => 'Expires year',
Expand Down
Expand Up @@ -11,7 +11,6 @@
use Spryker\Shared\DummyPayment\DummyPaymentConfig;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class InvoiceSubForm extends AbstractSubForm
{
Expand Down Expand Up @@ -56,11 +55,11 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @deprecated Use `configureOptions()` instead.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*
* @return void
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function setDefaultOptions(OptionsResolver $resolver)
{
$this->configureOptions($resolver);
}
Expand Down

0 comments on commit da4ad3f

Please sign in to comment.