Return to Snippet

Revision: 40296
at January 29, 2011 01:11 by JohnnyGamba


Initial Code
function yourmodulename_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'thisformid'){
    $form['field']['#prefix'] = 'This text gets overwritten by the after build'; 
    $form['#after_build'][] = 'yourmodulename_after_build'; //Calls function
    //drupal_add_css('hello.css'); This line does not work when validation fails
  }
}

function yourmodulename_after_build($form, &$form_state) {
  $form['field']['#prefix'] = 'This text will rule them all!'; 
  drupal_add_css('hello.css'); //This line works even after validation fails.
  return $form;
}

Initial URL

                                

Initial Description

                                

Initial Title
After Build use in Drupal

Initial Tags
drupal

Initial Language
PHP