function content_set_nested_elements in Content Construction Kit (CCK) 6.3
Helper function to set a value in a form element, no matter how deeply nested it is in the form.
Parameters
$form: The form array to search.
$field_name: The name or key of the form elements to return. Can be a field name, a group name, or a sub-field.
$value: The value to set the element to. Should be an array that matches the part of the form that is being altered.
Return value
TRUE or FALSE, depending on whether the element was discovered and set.
2 calls to content_set_nested_elements()
- content_add_more_js in includes/
content.node_form.inc - Menu callback for AHAH addition of new empty widgets.
- content_multigroup_add_more_js in modules/
content_multigroup/ content_multigroup.node_form.inc - Menu callback for AHAH addition of new empty widgets.
File
- ./
content.module, line 2891 - Allows administrators to associate custom fields to content types.
Code
function content_set_nested_elements(&$form, $field_name, $value) {
$success = FALSE;
$elements =& content_get_nested_elements($form, $field_name);
if (!empty($elements)) {
foreach ($elements as &$element) {
$element = $value;
$success = TRUE;
}
}
return $success;
}