function _editablefields_make_form_ids_unique in Editable Fields 5.2
Same name and namespace in other branches
- 5.3 editablefields.module \_editablefields_make_form_ids_unique()
- 5 editablefields.module \_editablefields_make_form_ids_unique()
1 call to _editablefields_make_form_ids_unique()
- theme_views_editablefields_handle_field in ./
editablefields.module - Themeable function to handle displaying a specific field.
File
- ./
editablefields.module, line 120
Code
function _editablefields_make_form_ids_unique($form, $nid) {
// much of this code is from form_builder. we set input elements' #id to a
// unique id by postpending -$nid.
if (!empty($form['#type']) && ($info = _element_info($form['#type']))) {
// overlay $info onto $form, retaining preexisting keys in $form
$form += $info;
}
if (isset($form['#input']) && $form['#input']) {
$form['#id'] = isset($form['#id']) ? $form['#id'] : 'edit-' . implode('-', $form['#parents']);
$form['#id'] .= '-' . $nid;
}
// recurse through sub-elements
foreach (element_children($form) as $key) {
// don't squash an existing tree value
if (!isset($form[$key]['#tree'])) {
$form[$key]['#tree'] = $form['#tree'];
}
// don't squash existing parents value
if (!isset($form[$key]['#parents'])) {
// Check to see if a tree of child elements is present. If so, continue down the tree if required.
$form[$key]['#parents'] = $form[$key]['#tree'] && $form['#tree'] ? array_merge($form['#parents'], array(
$key,
)) : array(
$key,
);
}
$form[$key] = _editablefields_make_form_ids_unique($form[$key], $nid);
}
return $form;
}