Issue using "required_if" validation rule in form builder
kiltedup - 11 months ago
I think this is a Laravel issue but posting here to see if anyone has encountered this and can suggest a solution. I had a form with a bunch of custom validation. This was working on Pyro 3.0 but since the site was upgraded to 3.3 it has stopped working.
Issue is that if a 'required_if' rule is used, any subsequent rules are still processed. Whereas before they would be skipped. Example rules on two fields :
'sosParent' => [ 'type' => 'anomaly.field_type.select', 'required' => true, 'config' => [ 'default_value' => 'Yes', 'mode' => 'radio', 'options' => [ 'Yes' => 'Yes', 'No' => 'No', ], ], ], ], 'sosTel' => [ 'type' => 'anomaly.field_type.text', 'required' => false, 'config' => [ 'type' => 'tel' ], 'rules' => [ 'required_if:sosParent,No|digits:11' ], ],
Before - if my sosParent field was set to 'Yes' then the 'digits' rule on sosTel was ignored. But now it is still enforced. This sosTel field only appears when sosParent is 'No' so the error is never shown.
If that makes sense, any suggestions on how to ignore the second rule ????