Search code examples
phpjqueryvalidationdrupaldrupal-7

Drupal validation for nested field element


I have a drupal form for save details, I wrote validation for each element in the form. Following method is using for display errors. Then it automatically highlighted the required fields.

form_set_error('field_athletes_male', 'Athletes Male field is required.'); 

My problem is there is nested element names like as follows

field_coaching_programme[und][0][field_organisation_delivered_by][und][0][value]

Validation message is shown successfully but element is not highlighted


Solution

  • Tried following code and working as expected

    form_set_error('field_coaching_programme][und][0][field_organisation_delivered_by', 'Organisation delivered by field is required.');