Constraints involving several fields
Klund8 opened this issue · 1 comments
Klund8 commented
It would be interesting to be able to add constraints involving several fields. It could be done by giving access for the field being verified to the other fields' values.
Typical use case:
- "Choose your password"
- "Type your password again"
The constraint would here check the equality between the two.
Gregwar commented
This should be OK right now:
<?php
// Adds a constraint on the whole form
$form->addConstraint(function($form) {
if ($form->getValue('pass1') != $form->getValue('pass2')) {
return 'The passwords are different';
}
});
+Unit test added