Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 2.8.19 |
This issue appears when form is used without entity/data_class. Both groups "Basic' and 'Strict' are validated even if there are violations in 'Basic'.
I also get the error: The Symfony\Component\Validator\Constraints\GroupSequence::getIterator method is deprecated since version 2.5 and will be removed in 3.0. in Symfony\Component\Validator\Constraints\GroupSequence.php on line 107
which is caused in by Symfony\Component\Form\Extension\Validator\Constraints\FormValidator.php:(84)
The Form
and Validator
components are working standalone outside of symfony distribution, with all the dependencies also available.
Here is how the form is configured:
class MyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add("name", null, [
"constraints" => new NotBlank(["groups" => ["Basic"]])
])
->add("phone", MyPhoneType::class, [
"constraints" => [
new NotBlank(["groups" => ["Basic"]]),
new PhoneNumber(["groups" => ["Strict"])
]
])
->add("email", EmailType::class, [
"constraints" => [
new NotBlank(["groups" => ["Basic"]]),
new Email(["groups" => ["Strict"]]),
],
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
"validation_groups" => new GroupSequence(["Basic", "Strict"])
]);
}
}