I've got paragraphs type with two fields which I've added as a field into my vocabulary.
I've added validation function (#validate
) into $form
using hook_form_FORM_ID_alter
where I'm validating values of these fields, however when I'm using the machine name of the paragraph field, all widgets are highlighted. My aim is to highlight only the one which fails.
The structure of that paragraph field (field_sor_rule
) is like:
// var_dump($form_state->getValue('field_sor_rule'));
array (size=3)
0 =>
array (size=3)
'subform' =>
array (size=2)
'field_sor_rule' =>
array (size=5)
0 =>
array (size=2)
'value' => string '1' (length=1)
'_weight' => string '0' (length=1)
I've tried already referencing it as:
$form_state->setErrorByName("field_sor_rule[0][subform][field_sor_rule][0]",
t('Please enter a valid value!'));
and:
$form_state->setErrorByName("field_sor_rule_0_subform_field_sor_rule_0]",
t('Please enter a valid value!'));
but without success.
What would be a valid syntax?