You are here

public function EntityInlineEntityFormController::removeFormSubmit in Inline Entity Form 7

Handles the submission of a remove form. Decides what should happen to the entity after the removal confirmation.

Parameters

$remove_form: The remove form.

$form_state: The form state of the parent form.

Return value

IEF_ENTITY_UNLINK or IEF_ENTITY_UNLINK_DELETE.

File

includes/entity.inline_entity_form.inc, line 368
Defines the base inline entity form controller.

Class

EntityInlineEntityFormController
@file Defines the base inline entity form controller.

Code

public function removeFormSubmit($remove_form, &$form_state) {
  $entity = $remove_form['#entity'];
  list($entity_id) = entity_extract_ids($this->entityType, $entity);
  $form_values = drupal_array_get_nested_value($form_state['values'], $remove_form['#parents']);

  // This entity hasn't been saved yet, we can just unlink it.
  if (empty($entity_id)) {
    return IEF_ENTITY_UNLINK;
  }

  // If existing entities can be referenced, the delete happens only when
  // specifically requested (the "Permanently delete" checkbox).
  if ($this
    ->getSetting('allow_existing') && empty($form_values['delete'])) {
    return IEF_ENTITY_UNLINK;
  }
  return IEF_ENTITY_UNLINK_DELETE;
}