If I have a multiple field (ajax) required: FIELD_A (N), and I want it not required if: FIELD_B has a certain value. How can I do ? Any function in $ form_state?
2
Use states to style the input as required. This won't actually perform any validation but will add the required asterisk to the field when field B has a certain value.
$form['FIELD_A']['#states'] = [
'required' => array(
':input[name="FIELD_B"]' => array('value' => 'foo'),
),
];
Then use custom validation to actually check FIELD_A has the correct value depending on the value of FIELD_B.