I am using 2 List(Text) fields in my form (that are required) and this fields aren't highlighted neither filled with the "@title fields is required" message when not validated. It seems this is due to $element arrays nesting for this specific field type.
Tried some debug and form altering but didn't find any working fix/patch so far ...

Review and possibile patch required, if bug confirmed.

Comments

itamair created an issue. See original summary.

itamair’s picture

Issue summary: View changes
nikunjkotecha’s picture

It seems this is related to how Drupal works. For list fields default / empty value it uses "_none" as value which actually is valid value as per HTML5 / jQuery validation library.

Will keep checking further to find a proper fix for this.

jelle_s’s picture

nikunjkotecha’s picture

Status: Needs work » Closed (won't fix)

Thanks @Jelle_S for pointing into right direction. Closing this one as it needs to be fixed in core.

khaldoon_masud’s picture

I applied a hack using the form_alter hook:

$empty_option = ['' => $form['field_name']['widget']['#options']['_none']];
unset($form['field_name']['widget']['#options']['_none']);
$form['field_name']['widget']['#options'] = $empty_option + $form['field_name']['widget']['#options'];