I have a webform with a composite component that allows multiple rows to be added. The structure is something like this, in case that makes it clearer:
webform sample_details - composite component which allows multiple 'rows', containing: sample_ref date_sampled (field I want to set the error on)
I followed 'method 2 - webform handler' on this guide. I'm able to do the validation itself and set an error on other components, but not on sub-components in the composite one.
This post addresses a similar problem, but the technique hasn't helped me.
$form_state->setErrorByName( 'date_sampled', $this->t( 'must not have a sample date in the future.' ) );
$form_state->setErrorByName( 'sample_details][date_sampled]', $this->t( 'must not have a sample date in the future.' ) );
and a few other things but it seems like I'm missing something. It seems that
setErrorByName can't work on sub-components because they don't have a standard
#parents array? Is there a way of achieving this without having to switch to 'the old way'?