I think the documentation for #after_build is in error for Drupal 6. If you have CVS-access and believe the suggested change is correct, please committ it.

The important part is the parameters to the function that should be changed from ($form, $form_element) to ($form_element, &$form_state).
I have attached a patch against the full html file found trough viewvc, but do you really edit it that way - without a preprocessor like Doxygen?

A more human-readable form of the suggestion follows here:
----------------

#after_build

An array of function names which will be called after the form is built.

Usage example (system.admin.inc and system.module):

  $form['file_directory_path'] = array(
    '#type' => 'textfield',
    '#title' => t('File system path'),
    '#default_value' => file_directory_path(),
    '#maxlength' => 255,
    '#description' => t('A file system path where the files will be stored. This directory must exist and be writable by Drupal. If the download method is set to public, this directory must be relative to the Drupal installation directory and be accessible over the web. If the download method is set to private, this directory should not be accessible over the web. Changing this location will modify all download paths and may cause unexpected problems on an existing site.'),
    '#after_build' => array('system_check_directory'),
  );
...
function system_check_directory($form_element, &$form_state) {
  file_check_directory($form_element['#value'], FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
  return $form_element;
}

Another example is node_body_field which uses node_teaser_js.

Property names without # signs causes havoc.

CommentFileSizeAuthor
diff-forms_ref_after_build.diff6.95 KBemok

Comments

ezyang’s picture

Status: Active » Needs review

The correction looks correct; and yes, those files are hand-edited. Which I find hilarious, because there's syntax coloring in the HTML. :-)

brunodbo’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: Documentation in CVS » documentation
Barry Madore’s picture

Moving

betz’s picture

Changed the component to reflect the new component categorization. See http://drupal.org/node/301443

Patch failed to apply. More information can be found at http://testing.drupal.org/node/13904. If you need help with creating patches please look at http://drupal.org/patch/create

Patch failed to apply. More information can be found at http://testing.drupal.org/node/13903. If you need help with creating patches please look at http://drupal.org/patch/create

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

jhodgdon’s picture

Status: Needs work » Closed (fixed)

This has already been fixed, apparently.