From 61944ac2206dca964ee3aff1f5589710afddc33a Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Tue, 30 Apr 2019 12:05:18 +0200 Subject: [PATCH 1/4] Refactor form pageparts to use new value_constraints param --- .../Entity/PageParts/CheckboxPagePart.php | 21 +++++++------- .../Entity/PageParts/ChoicePagePart.php | 20 ++++++------- .../Entity/PageParts/EmailPagePart.php | 23 +++++++-------- .../Entity/PageParts/FileUploadPagePart.php | 20 ++++++------- .../PageParts/MultiLineTextPagePart.php | 22 +++++++-------- .../PageParts/SingleLineTextPagePart.php | 23 +++++++-------- .../Form/BooleanFormSubmissionType.php | 26 +++++++++++------ .../Form/ChoiceFormSubmissionType.php | 27 +++++++++++++----- .../Form/EmailFormSubmissionType.php | 26 +++++++++++------ .../Form/FileFormSubmissionType.php | 26 +++++++++++------ .../Form/StringFormSubmissionType.php | 26 +++++++++++------ .../Form/TextFormSubmissionType.php | 28 +++++++++++++------ 12 files changed, 177 insertions(+), 111 deletions(-) diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php index f18852229d..9081b36c31 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php @@ -94,33 +94,34 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $bfsf = new BooleanFormSubmissionField(); - $bfsf->setFieldName('field_' . $this->getUniqueId()); + $bfsf->setFieldName('field_'.$this->getUniqueId()); $bfsf->setLabel($this->getLabel()); $bfsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $bfsf; - $constraints = array(); + $data['formwidget_'.$this->getUniqueId()] = $bfsf; + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } - $formBuilder->add('formwidget_' . $this->getUniqueId(), + $formBuilder->add( + 'formwidget_'.$this->getUniqueId(), BooleanFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired(), - ) + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php index f485b74110..fb0d3b1260 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php @@ -80,8 +80,8 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { @@ -89,17 +89,17 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields $choices = array_map('trim', $choices); $cfsf = new ChoiceFormSubmissionField(); - $cfsf->setFieldName('field_' . $this->getUniqueId()); + $cfsf->setFieldName('field_'.$this->getUniqueId()); $cfsf->setLabel($this->getLabel()); $cfsf->setChoices($choices); $cfsf->setRequired($this->required); $cfsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $cfsf; - $constraints = array(); + $data['formwidget_'.$this->getUniqueId()] = $cfsf; + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } @@ -107,17 +107,17 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields } $formBuilder->add( - 'formwidget_' . $this->getUniqueId(), + 'formwidget_'.$this->getUniqueId(), ChoiceFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), 'required' => $this->getRequired(), 'expanded' => $this->getExpanded(), 'multiple' => $this->getMultiple(), 'choices' => $choices, 'placeholder' => $this->getEmptyValue(), - 'constraints' => $constraints, - ) + 'value_constraints' => $constraints, + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php index c6367fc782..2fd021523f 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php @@ -126,40 +126,41 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $efsf = new EmailFormSubmissionField(); - $efsf->setFieldName('field_' . $this->getUniqueId()); + $efsf->setFieldName('field_'.$this->getUniqueId()); $efsf->setLabel($this->getLabel()); $efsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $efsf; + $data['formwidget_'.$this->getUniqueId()] = $efsf; - $constraints = array(); + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } - $options = array(); + $options = []; if (!empty($this->errorMessageInvalid)) { $options['message'] = $this->getErrorMessageInvalid(); } $constraints[] = new Email($options); - $formBuilder->add('formwidget_' . $this->getUniqueId(), + $formBuilder->add( + 'formwidget_'.$this->getUniqueId(), EmailFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired(), - ) + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php index 20da6bfaca..618c7b469c 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php @@ -37,22 +37,22 @@ class FileUploadPagePart extends AbstractFormPagePart * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $ffsf = new FileFormSubmissionField(); - $ffsf->setFieldName('field_' . $this->getUniqueId()); + $ffsf->setFieldName('field_'.$this->getUniqueId()); $ffsf->setLabel($this->getLabel()); $ffsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $ffsf; + $data['formwidget_'.$this->getUniqueId()] = $ffsf; - $constraints = array(); + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } @@ -60,13 +60,13 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields } $formBuilder->add( - 'formwidget_' . $this->getUniqueId(), + 'formwidget_'.$this->getUniqueId(), FileFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired(), - ) + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php index 14daa26043..6d7169d145 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php @@ -157,29 +157,29 @@ public function getErrorMessageRequired() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $mfsf = new TextFormSubmissionField(); - $mfsf->setFieldName('field_' . $this->getUniqueId()); + $mfsf->setFieldName('field_'.$this->getUniqueId()); $mfsf->setLabel($this->getLabel()); $mfsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $mfsf; + $data['formwidget_'.$this->getUniqueId()] = $mfsf; - $constraints = array(); + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } if ($this->getRegex()) { - $options = array('pattern' => $this->getRegex()); + $options = ['pattern' => $this->getRegex()]; if (!empty($this->errorMessageRegex)) { $options['message'] = $this->errorMessageRegex; } @@ -187,13 +187,13 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields } $formBuilder->add( - 'formwidget_' . $this->getUniqueId(), + 'formwidget_'.$this->getUniqueId(), TextFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired(), - ) + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php index 5547a74c33..1757d7689a 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php @@ -157,42 +157,43 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $sfsf = new StringFormSubmissionField(); - $sfsf->setFieldName('field_' . $this->getUniqueId()); + $sfsf->setFieldName('field_'.$this->getUniqueId()); $sfsf->setLabel($this->getLabel()); $sfsf->setSequence($sequence); $data = $formBuilder->getData(); - $data['formwidget_' . $this->getUniqueId()] = $sfsf; + $data['formwidget_'.$this->getUniqueId()] = $sfsf; - $constraints = array(); + $constraints = []; if ($this->getRequired()) { - $options = array(); + $options = []; if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } if ($this->getRegex()) { - $options = array('pattern' => $this->getRegex()); + $options = ['pattern' => $this->getRegex()]; if (!empty($this->errorMessageRegex)) { $options['message'] = $this->errorMessageRegex; } $constraints[] = new Regex($options); } - $formBuilder->add('formwidget_' . $this->getUniqueId(), + $formBuilder->add( + 'formwidget_'.$this->getUniqueId(), StringFormSubmissionType::class, - array( + [ 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired(), - ) + ] ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php index 233d12aecf..8ae8d0d271 100644 --- a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php @@ -14,23 +14,33 @@ class BooleanFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(array('label', 'required', 'constraints'), null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys(['label', 'required', 'constraints'], null); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); $builder->add('value', CheckboxType::class, $fieldOptions); } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults([ - 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\BooleanFormSubmissionField', - ]); + $resolver->setDefaults( + [ + 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\BooleanFormSubmissionField', + 'value_constraints' => [], + ] + ); } /** diff --git a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php index 8f81ecc59f..f83b5bf571 100644 --- a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php @@ -14,14 +14,24 @@ class ChoiceFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(['label', 'required', 'expanded', 'multiple', 'choices', 'placeholder', 'constraints'], null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys( + ['label', 'required', 'expanded', 'multiple', 'choices', 'placeholder', 'constraints'], + null + ); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); $fieldOptions['choices'] = array_flip($fieldOptions['choices']); $fieldOptions['empty_data'] = null; @@ -38,12 +48,15 @@ public function getBlockPrefix() public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults([ + $resolver->setDefaults( + [ 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\ChoiceFormSubmissionField', 'choices' => [], 'placeholder' => null, 'expanded' => null, 'multiple' => null, - ]); + 'value_constraints' => [], + ] + ); } } diff --git a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php index ab31bb4a93..0516ae3483 100644 --- a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php @@ -14,22 +14,32 @@ class EmailFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(array('label', 'required', 'constraints'), null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys(['label', 'required', 'constraints'], null); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); $builder->add('value', EmailType::class, $fieldOptions); } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\EmailFormSubmissionField', - )); + $resolver->setDefaults( + [ + 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\EmailFormSubmissionField', + 'value_constraints' => [], + ] + ); } /** diff --git a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php index 1ec4f5df04..f140891712 100644 --- a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php @@ -14,23 +14,33 @@ class FileFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options An array with options + * @param array $options An array with options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(array('label', 'required', 'constraints'), null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys(['label', 'required', 'constraints'], null); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); $builder->add('file', FileType::class, $fieldOptions); } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\FileFormSubmissionField', - )); + $resolver->setDefaults( + [ + 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\FileFormSubmissionField', + 'value_constraints' => [], + ] + ); } /** diff --git a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php index 395358fdee..e0edcff188 100644 --- a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php @@ -14,22 +14,32 @@ class StringFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(array('label', 'required', 'constraints'), null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys(['label', 'required', 'constraints'], null); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); $builder->add('value', TextType::class, $fieldOptions); } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\StringFormSubmissionField', - )); + $resolver->setDefaults( + [ + 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\StringFormSubmissionField', + 'value_constraints' => [], + ] + ); } /** diff --git a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php index 5b6d5afdc2..0a553967c9 100644 --- a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php @@ -14,24 +14,34 @@ class TextFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { - $keys = array_fill_keys(array('label', 'required', 'constraints'), null); - $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) { - return isset($v); - }); - $fieldOptions['attr'] = array('rows' => '6'); + if (isset($options['value_constraints'])) { + $options['constraints'] = $options['value_constraints']; + } + + $keys = array_fill_keys(['label', 'required', 'constraints'], null); + $fieldOptions = array_filter( + array_replace($keys, array_intersect_key($options, $keys)), + function ($v) { + return isset($v); + } + ); + $fieldOptions['attr'] = ['rows' => '6']; $builder->add('value', TextareaType::class, $fieldOptions); } public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\TextFormSubmissionField', - )); + $resolver->setDefaults( + [ + 'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\TextFormSubmissionField', + 'value_constraints' => [], + ] + ); } /** From d6231dfff81c01e2c8dd13f7f7cda44a517d507f Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Tue, 30 Apr 2019 13:17:22 +0200 Subject: [PATCH 2/4] use value_constraints in generated pps --- .../Entity/PageParts/CheckboxPagePart/CheckboxPagePart.php | 2 +- .../pagepart/Entity/PageParts/ChoicePagePart/ChoicePagePart.php | 2 +- .../pagepart/Entity/PageParts/EmailPagePart/EmailPagePart.php | 2 +- .../Entity/PageParts/FileUploadPagePart/FileUploadPagePart.php | 2 +- .../PageParts/MultiLineTextPagePart/MultiLineTextPagePart.php | 2 +- .../PageParts/SingleLineTextPagePart/SingleLineTextPagePart.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/CheckboxPagePart/CheckboxPagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/CheckboxPagePart/CheckboxPagePart.php index e7c1273ecd..fc32bc8f43 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/CheckboxPagePart/CheckboxPagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/CheckboxPagePart/CheckboxPagePart.php @@ -146,7 +146,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields BooleanFormSubmissionType::class, array( 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired() ) ); diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/ChoicePagePart/ChoicePagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/ChoicePagePart/ChoicePagePart.php index 989f437cf5..e7849f0a7f 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/ChoicePagePart/ChoicePagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/ChoicePagePart/ChoicePagePart.php @@ -123,7 +123,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields 'multiple' => $this->getMultiple(), 'choices' => $choices, 'placeholder' => $this->getEmptyValue(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, ) ); $formBuilder->setData($data); diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/EmailPagePart/EmailPagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/EmailPagePart/EmailPagePart.php index 16cf56b98d..b4108067a5 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/EmailPagePart/EmailPagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/EmailPagePart/EmailPagePart.php @@ -185,7 +185,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields EmailFormSubmissionType::class, array( 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired() ) ); diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/FileUploadPagePart/FileUploadPagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/FileUploadPagePart/FileUploadPagePart.php index de599f1466..8f4293bf90 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/FileUploadPagePart/FileUploadPagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/FileUploadPagePart/FileUploadPagePart.php @@ -71,7 +71,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields FileFormSubmissionType::class, array( 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired() ) ); diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/MultiLineTextPagePart/MultiLineTextPagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/MultiLineTextPagePart/MultiLineTextPagePart.php index 077b81ad1a..0d657803d3 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/MultiLineTextPagePart/MultiLineTextPagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/MultiLineTextPagePart/MultiLineTextPagePart.php @@ -219,7 +219,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields TextFormSubmissionType::class, array( 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired() ) ); diff --git a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/SingleLineTextPagePart/SingleLineTextPagePart.php b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/SingleLineTextPagePart/SingleLineTextPagePart.php index d989b1030f..273adb9c57 100644 --- a/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/SingleLineTextPagePart/SingleLineTextPagePart.php +++ b/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/pagepart/Entity/PageParts/SingleLineTextPagePart/SingleLineTextPagePart.php @@ -218,7 +218,7 @@ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields StringFormSubmissionType::class, array( 'label' => $this->getLabel(), - 'constraints' => $constraints, + 'value_constraints' => $constraints, 'required' => $this->getRequired() ) ); From 3b7cf63bb45d12ca4f3c1c3d50bf5bb8a0976c49 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Tue, 30 Apr 2019 13:25:37 +0200 Subject: [PATCH 3/4] apply styleci diff --- .../FormBundle/Entity/PageParts/CheckboxPagePart.php | 4 ++-- src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php | 4 ++-- src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php | 4 ++-- .../FormBundle/Entity/PageParts/FileUploadPagePart.php | 4 ++-- .../FormBundle/Entity/PageParts/MultiLineTextPagePart.php | 4 ++-- .../FormBundle/Entity/PageParts/SingleLineTextPagePart.php | 4 ++-- src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php index 9081b36c31..88fdee3785 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/CheckboxPagePart.php @@ -94,8 +94,8 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php index fb0d3b1260..bac9db1ce9 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/ChoicePagePart.php @@ -80,8 +80,8 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php index 2fd021523f..9c97b4e010 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/EmailPagePart.php @@ -126,8 +126,8 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php index 618c7b469c..3fd4f90305 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/FileUploadPagePart.php @@ -37,8 +37,8 @@ class FileUploadPagePart extends AbstractFormPagePart * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php index 6d7169d145..e2f318c3a5 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/MultiLineTextPagePart.php @@ -157,8 +157,8 @@ public function getErrorMessageRequired() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php b/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php index 1757d7689a..94b95e41ff 100644 --- a/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php +++ b/src/Kunstmaan/FormBundle/Entity/PageParts/SingleLineTextPagePart.php @@ -157,8 +157,8 @@ public function getDefaultView() * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder - * @param ArrayObject $fields The fields - * @param int $sequence The sequence of the form field + * @param ArrayObject $fields The fields + * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { diff --git a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php index 8ae8d0d271..dc945f4295 100644 --- a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php @@ -14,7 +14,7 @@ class BooleanFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php index f83b5bf571..38c67eed3d 100644 --- a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php @@ -14,7 +14,7 @@ class ChoiceFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php index 0516ae3483..51826dd5f6 100644 --- a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php @@ -14,7 +14,7 @@ class EmailFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php index f140891712..0ef7531502 100644 --- a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php @@ -14,7 +14,7 @@ class FileFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options An array with options + * @param array $options An array with options */ public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php index e0edcff188..f8d0db81a1 100644 --- a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php @@ -14,7 +14,7 @@ class StringFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { diff --git a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php index 0a553967c9..c69f07af11 100644 --- a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php @@ -14,7 +14,7 @@ class TextFormSubmissionType extends AbstractType { /** * @param FormBuilderInterface $builder The form builder - * @param array $options The options + * @param array $options The options */ public function buildForm(FormBuilderInterface $builder, array $options) { From f9b455a01581f24f3b8d5ff7940440e9c09409ab Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Wed, 8 May 2019 09:58:07 +0200 Subject: [PATCH 4/4] fix check constraints --- src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php | 2 +- src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php index dc945f4295..603c5df026 100644 --- a/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php @@ -18,7 +18,7 @@ class BooleanFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; } diff --git a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php index 38c67eed3d..1ff86aeaf2 100644 --- a/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/ChoiceFormSubmissionType.php @@ -18,7 +18,7 @@ class ChoiceFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; } diff --git a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php index 51826dd5f6..79bc7ddccc 100644 --- a/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php @@ -18,7 +18,7 @@ class EmailFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; } diff --git a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php index 0ef7531502..410bd3d351 100644 --- a/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php @@ -18,7 +18,7 @@ class FileFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; } diff --git a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php index f8d0db81a1..cb55dd4b95 100644 --- a/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php @@ -18,7 +18,7 @@ class StringFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; } diff --git a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php index c69f07af11..172a7399f5 100644 --- a/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php +++ b/src/Kunstmaan/FormBundle/Form/TextFormSubmissionType.php @@ -18,7 +18,7 @@ class TextFormSubmissionType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - if (isset($options['value_constraints'])) { + if (isset($options['value_constraints']) && !empty($options['value_constraints'])) { $options['constraints'] = $options['value_constraints']; }