You are here

function inline_entity_form_remove_confirm in Inline Entity Form 7

Remove form submit callback.

The row is identified by #ief_row_delta stored on the triggering element. This isn't an #element_validate callback to avoid processing the remove form when the main form is submitted.

Parameters

$form: The complete parent form.

$form_state: The form state of the parent form.

1 string reference to 'inline_entity_form_remove_confirm'
inline_entity_form_remove_form in ./inline_entity_form.module
Wraps and returns the remove form provided by the passed-in controller.

File

./inline_entity_form.module, line 1237
Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent -> children one (for example, order -> line items), where the child entities are never managed outside the…

Code

function inline_entity_form_remove_confirm($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $element = inline_entity_form_get_element($form, $form_state);
  $ief_id = $element['#ief_id'];
  $instance = $form_state['inline_entity_form'][$ief_id]['instance'];
  $delta = $form_state['triggering_element']['#ief_row_delta'];
  $remove_form = $element['entities'][$delta]['form'];

  // Instantiate the controller and submit the form.
  $controller = inline_entity_form_get_controller($instance);
  $status = $controller
    ->removeFormSubmit($remove_form, $form_state);
  if ($status == IEF_ENTITY_UNLINK_DELETE) {
    $settings = $form_state['inline_entity_form'][$ief_id]['settings'];
    list($entity_id) = entity_extract_ids($settings['entity_type'], $remove_form['#entity']);
    $form_state['inline_entity_form'][$ief_id]['delete'][] = $entity_id;
    unset($form_state['inline_entity_form'][$ief_id]['entities'][$delta]);
  }
  elseif ($status == IEF_ENTITY_UNLINK) {
    unset($form_state['inline_entity_form'][$ief_id]['entities'][$delta]);
  }
}