wesley tanaka

Drupal 6 Form API Custom Element Processing Order

On view:

  1. #value OR form_type_ELEMENT_value($element, $edit=FALSE) (convert the incoming #value or #default_value into the internal element structure)
  2. #process
  3. #after_build

On submit:

  1. #value OR form_type_ELEMENT_value($element, $edit=FALSE) (convert the incoming #value or #default_value into the internal element structure)
  2. #process
  3. #after_build
  4. #element_validate (convert the internal element structure into an externally visible #value -- see password_confirm_validate() for an example)

Example of form_type_ELEMENT_value($element, $edit=FALSE):

<?php
function form_type_example_field_value($element, $edit = FALSE) {
if (func_num_args() == 1) {
return $element['#default_value'];
}
}
?>

If you are using form_set_value() to clear sub element values inside the #element_validate function, be sure to clear the sub element values before setting the main element value, or the main element value may get corrupted.

Suggested Links

Syndicate content