How can I add an ID attribute on each row for a field? I need an ID at the row level for 'remove item' functionality to remove that row from the display. Or is there a better/standard way to handle removal in a field_multiple_value_form? Here is how I define the remove button:
$element['remove'] = array(
'#type' => 'button',
'#value' => t('Remove item'),
'#weight' => 10,
'#input' => TRUE,
'#name' => 'field_video_callout_remove-' . $delta,
'#button_type' => 'submit form-remove',
'#executes_submit_callback' => TRUE,
'#limit_validation_errors' => FALSE,
'#process' => array('ajax_process_form'),
'#theme_wrappers' => array('button'),
'#prefix' => '<div style="float:right;margin-top:5%;">',
'#suffix' => '</div>',
'#ajax' => array(
'callback' => 'field_video_callout_field_widget_form_remove',
'wrapper' => 'row-' . $delta,
'effect' => 'fade',
'method' => 'replace',
),
);
Here is the callback:
function field_video_callout_field_widget_form_remove($form, $form_state) {
$button = $form_state['clicked_button'];
$element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
$langcode = $element['#language'];