function form_builder_get_elements in Form Builder 6
Same name and namespace in other branches
- 7.2 includes/form_builder.api.inc \form_builder_get_elements()
- 7 includes/form_builder.api.inc \form_builder_get_elements()
Recursive function to retrieve multiple elements within a form structure.
Parameters
$form: A complete hierarchical FAPI structure.
$element_ids: An array of unique identifiers for elements that are to be retreived. These identifiers match against the special property "#form_builder['element_id']", which is not available in normal FAPI structures. It must be added by the respective module that is providing support for a certain field type.
For example, CCK provides a unique identifier for each field such as "field_my_name". This field name must be added to the form array as #form_builder['element_id'] = 'field_my_name' in CCK's implementation of hook_form_builder_load().
Return value
A single Form API element array.
2 calls to form_builder_get_elements()
- form_builder_get_element in includes/
form_builder.api.inc - Function to retrieve a single element within a form structure.
- _form_builder_add_element in includes/
form_builder.admin.inc - Menu callback helper for adding or cloning a field.
File
- includes/
form_builder.api.inc, line 179 - form_builder.api.inc Universally used API functions within the Form builder module.
Code
function form_builder_get_elements(&$form, $element_ids) {
$elements = array();
foreach (element_children($form) as $key) {
if (isset($form[$key]['#form_builder']['element_id']) && in_array($form[$key]['#form_builder']['element_id'], $element_ids)) {
$elements[$form[$key]['#form_builder']['element_id']] = $form[$key];
}
$additional_elements = form_builder_get_elements($form[$key], $element_ids);
$elements = array_merge($elements, $additional_elements);
}
return $elements;
}