diff --git a/src/Form/Type/NewOrderType.php b/src/Form/Type/NewOrderType.php index 8bf4d6fd..9d76ec8c 100644 --- a/src/Form/Type/NewOrderType.php +++ b/src/Form/Type/NewOrderType.php @@ -13,11 +13,13 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; +use Symfony\Component\Validator\Constraints\Count; final class NewOrderType extends AbstractResourceType { public function buildForm(FormBuilderInterface $builder, array $options) { + $validationGroups = ['sylius']; $builder ->add('promotionCoupon', PromotionCouponToCodeType::class, [ 'by_reference' => false, @@ -37,6 +39,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, + 'constraints' => [ + new Count(['min' => 1, 'max' => 1, 'groups' => $validationGroups]), + ], ]) ->add('shipments', CollectionType::class, [ 'entry_type' => ShipmentType::class, diff --git a/src/Resources/config/validation.xml b/src/Resources/config/validation.xml deleted file mode 100644 index 94a0075a..00000000 --- a/src/Resources/config/validation.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - -