构建后在Drupal中的使用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构建后在Drupal中的使用相关的知识,希望对你有一定的参考价值。

  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. }

以上是关于构建后在Drupal中的使用的主要内容,如果未能解决你的问题,请参考以下文章