Posted By

JohnnyGamba on 01/29/11


Tagged

drupal


Versions (?)

After Build use in Drupal


 / Published in: PHP
 

  1. function yourmodulename_form_alter(&$form, $form_state, $form_id) {
  2. if($form_id == 'thisformid'){
  3. $form['field']['#prefix'] = 'This text gets overwritten by the after build';
  4. $form['#after_build'][] = 'yourmodulename_after_build'; //Calls function
  5. //drupal_add_css('hello.css'); This line does not work when validation fails
  6. }
  7. }
  8.  
  9. function yourmodulename_after_build($form, &$form_state) {
  10. $form['field']['#prefix'] = 'This text will rule them all!';
  11. drupal_add_css('hello.css'); //This line works even after validation fails.
  12. return $form;
  13. }

Report this snippet  

You need to login to post a comment.