function field_collection_remove_js in Field collection 7
AJAX callback for removing a field collection item.
This returns the new page content to replace the page content made obsolete by the form submission.
See also
field_collection_remove_submit()
1 string reference to 'field_collection_remove_js'
- field_collection_field_widget_form in ./
field_collection.module - Implements hook_field_widget_form().
File
- ./
field_collection.module, line 1550 - Module implementing field collection field type.
Code
function field_collection_remove_js($form, $form_state) {
$button = $form_state['triggering_element'];
// Go one level up in the form, to the widgets container.
$element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -2));
$field_name = $element['#field_name'];
$langcode = $element['#language'];
$parents = $element['#field_parents'];
$field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
$field = $field_state['field'];
if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED) {
return;
}
return $element;
}