function bulk_photo_nodes_recursive_ajax in Bulk File Nodes 7
Adds an #ajax property recursively to all elements of a form.
Parameters
array $element: The first element to recursively apply #ajax to.
1 call to bulk_photo_nodes_recursive_ajax()
- bulk_photo_nodes_create_overrides in ./
bulk_photo_nodes.module - Generate batch override form for bulk_photo_nodes_add_form().
File
- ./
bulk_photo_nodes.module, line 754 - hooks and helper functions for bulk photo node.
Code
function bulk_photo_nodes_recursive_ajax(&$element) {
if (element_children($element)) {
foreach (element_children($element) as $child) {
bulk_photo_nodes_recursive_ajax($element[$child]);
}
if (empty($element['#ajax'])) {
$element['#ajax'] = array(
'event' => 'change',
'wrapper' => 'bpn-nodes',
'callback' => 'bulk_photo_nodes_add_form_ajax',
'method' => 'replace',
'progress' => array(
'type' => 'none',
),
);
}
elseif ($element['#ajax']['callback'] == 'field_add_more_js') {
$element['#element_validate'] = array(
'bulk_photo_nodes_add_more_button_validate',
);
$element['#ajax']['callback'] = 'bulk_photo_nodes_field_add_more_js';
}
if (!empty($element['#autocomplete_path'])) {
$field_info = field_info_field($element['#field_name']);
if ($field_info['type'] == 'entityreference') {
$element['#element_validate'] = array(
'bulk_photo_nodes_entityreference_autocomplete_validate',
);
}
}
elseif (!empty($element['#type']) && $element['#type'] == 'select') {
// @todo: Since applying the patch at https://www.drupal.org/node/2278141#comment-9299441
// (commit id 3c17363b01e6b4cff64544bb85bd9418c73c7ccd) 'tid' was changed to 'target_id'
// here, so bulk_photo_nodes_taxonomy_validate() is now acting on entity reference
// fields, and NOT on taxonomy reference fields. Need to figure out which reference
// fields this should actually be acting on, and whether the function should be renamed.
// Note also that select list validation issues may be related to https://www.drupal.org/node/2454031.
if (!empty($element['#value_key']) && $element['#value_key'] == 'target_id') {
$element['#element_validate'] = array(
'bulk_photo_nodes_taxonomy_validate',
);
}
}
}
else {
if (empty($element['#ajax'])) {
$element['#ajax'] = array(
'event' => 'change',
'wrapper' => 'bpn-nodes',
'callback' => 'bulk_photo_nodes_add_form_ajax',
'method' => 'replace',
'progress' => array(
'type' => 'none',
),
);
}
elseif ($element['#ajax']['callback'] == 'field_add_more_js') {
$element['#element_validate'] = array(
'bulk_photo_nodes_add_more_button_validate',
);
$element['#ajax']['callback'] = 'bulk_photo_nodes_field_add_more_js';
}
if (!empty($element['#autocomplete_path'])) {
// Add custom validation for autocomplete taxonomy textfields.
$field_info = field_info_field($element['#field_name']);
if ($field_info['type'] == 'entityreference') {
$element['#element_validate'] = array(
'bulk_photo_nodes_entityreference_autocomplete_validate',
);
}
}
elseif (!empty($element['#type']) && $element['#type'] == 'select') {
// Add custom validation for taxonomy selects.
if (!empty($element['#value_key']) && $element['#value_key'] == 'target_id') {
$element['#element_validate'] = array(
'bulk_photo_nodes_taxonomy_validate',
);
}
}
}
}