Altering a Drupal form after validation -


i have drupal 7 form after submitting it, validation happens. taking email address , doing database look-up see if user exists. if user exists, need alter form re-renders on page displays errors, removing fields. on error page, regardless of other validation errors have received (first name required, last name required etc.) 1 error message says "that email address in system" , no longer want display of other fields @ point except email address field , file upload field. i'm having trouble trying figure out how alter form after first submission based on validation.

thanks

what want add data $form_state variable in validation function can inform form function fields should provide.

untested example:

    function my_form($form, &$form_state){       $form['my_field1'] = array('#markup' => 'my default field');        // custom form_state variable       if ($form_state['change_fields']) {         $form['my_field2'] = array('#markup' => 'my new field');       }     }      function my_form_validate($form, &$form_state){       // if not valid reason {         form_set_error('my_field1','this did not validate');         $form_state['change_fields'] = true;       // }     } 

Comments