Archive for April, 2015

SOLVED!! How can you make form_set_error() affect the only form submitted?

DrupalĀ form_set_error() function provide validation message based field name. So if you have same field name in same page , after the submission you can see both fields are marked as red color(Error class). It validate or show message for right form but it provide error class for all element which are same.

I found a way to solve it. If you render those form using drupal_get_form then you can add one extra line in top to get rid of this problem.

for example :-

drupal_static_reset('form_set_error'); // adding this line makes you life out of hell.-)
$form = drupal_get_form('webform_client_form', $node, $submission);
return drupal_render($form);

Ref:- http://drupal.stackexchange.com/questions/29113/how-do-i-make-form-set-error-affect-the-submitted-form-only
Advertisements

,

Leave a comment