Jak w symfony 4 uzależnić jedno pole od drugiego.
Mam encję example
#src/Entity/Example.php <?php namespace App\Entity; class Example { private $id; /** * @Assert\NotBlank */ private $key; private $value; public function getKey(): ?int { return $this->key; } public function setKey(int $key): self { $this->key = $key; return $this; } public function getValue(): ?int { return $this->value; } public function setValue(int $value): self { $this->value = $value; return $this; } }
Z takiej encji buduję formularz
{ $builder ->add('key', IntegerType::class) ->add('value', IntegerType::class); }
W jaki sposób ustawić walidację na pole value, tylko wtedy gdy pole key ma wartość 1