From b6ee0d132322f2d18e5954e9386d1d8b0a8ef64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Fri, 30 Aug 2019 17:03:27 +0200 Subject: [PATCH] Enforce positive values for min quantities and price quantites. --- src/Entity/PriceInformations/Pricedetail.php | 1 + src/Form/Part/PricedetailType.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 4b674e79..6b359a37 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -115,6 +115,7 @@ class Pricedetail extends DBElement /** * @var int * @ORM\Column(type="integer") + * @Assert\Positive() */ protected $min_discount_quantity = 1; diff --git a/src/Form/Part/PricedetailType.php b/src/Form/Part/PricedetailType.php index 0794eaca..c9f0eade 100644 --- a/src/Form/Part/PricedetailType.php +++ b/src/Form/Part/PricedetailType.php @@ -48,8 +48,12 @@ class PricedetailType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { //No labels needed, we define translation in templates - $builder->add("min_discount_quantity", IntegerType::class); - $builder->add("price_related_quantity", IntegerType::class); + $builder->add("min_discount_quantity", IntegerType::class, [ + 'attr' => ['min' => 1] + ]); + $builder->add("price_related_quantity", IntegerType::class, [ + 'attr' => ['min' => 1] + ]); $builder->add("price", NumberType::class); $builder->add("currency", CurrencyEntityType::class, ['required' => false]); }