I have a a kind of conditional field for a sign up form where the user can optionally sign up with a mobile number or an email address.
I'm trying out a custom form validate eg.
function signup_validate($form, FormStateInterface $form_state) {
$mobile = $form_state->getValue('field_mobile');
$email = $form_state->getValue('field_email_address');
if ($email[0]['value'] != '' || $mobile[0]['value'] != '') {
$form_state->clearErrors();
}
}
Now clearErrors();
obviously clears all errors for the form even if other fields are invalid, I want to know how to clear the error only for field_mobile
or field_email_address