Enforce positive values for min quantities and price quantites.

This commit is contained in:
Jan Böhmer 2019-08-30 17:03:27 +02:00
parent 63508293bd
commit b6ee0d1323
2 changed files with 7 additions and 2 deletions

View file

@ -115,6 +115,7 @@ class Pricedetail extends DBElement
/**
* @var int
* @ORM\Column(type="integer")
* @Assert\Positive()
*/
protected $min_discount_quantity = 1;

View file

@ -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]);
}