You are here

function inline_entity_form_remove_form in Inline Entity Form 7

Wraps and returns the remove form provided by the passed-in controller.

Parameters

$controller: The inline entity form controller.

$remove_form: The form array that will receive the entity form.

$form_state: The form state of the parent form.

Return value

The form array containing the embedded remove form.

1 call to inline_entity_form_remove_form()
inline_entity_form_field_widget_form in ./inline_entity_form.module
Implements hook_field_widget_form().

File

./inline_entity_form.module, line 1185
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_form($controller, $remove_form, &$form_state) {

  // Build a deta suffix that's appended to button #name keys for uniqueness.
  $delta = $remove_form['#ief_id'] . '-' . $remove_form['#ief_row_delta'];

  // Retrieve the form provided by the controller.
  $remove_form = $controller
    ->removeForm($remove_form, $form_state);

  // Add the actions
  $remove_form['actions'] = array(
    '#type' => 'container',
    '#weight' => 100,
  );
  $remove_form['actions']['ief_remove_confirm'] = array(
    '#type' => 'submit',
    '#value' => t('Remove'),
    '#name' => 'ief-remove-confirm-' . $delta,
    '#limit_validation_errors' => array(
      $remove_form['#parents'],
    ),
    '#ajax' => array(
      'callback' => 'inline_entity_form_get_element',
      'wrapper' => 'inline-entity-form-' . $remove_form['#ief_id'],
    ),
    '#submit' => array(
      'inline_entity_form_remove_confirm',
    ),
    '#ief_row_delta' => $remove_form['#ief_row_delta'],
  );
  $remove_form['actions']['ief_remove_cancel'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#name' => 'ief-remove-cancel-' . $delta,
    '#limit_validation_errors' => array(),
    '#ajax' => array(
      'callback' => 'inline_entity_form_get_element',
      'wrapper' => 'inline-entity-form-' . $remove_form['#ief_id'],
    ),
    '#submit' => array(
      'inline_entity_form_close_row_form',
    ),
    '#ief_row_delta' => $remove_form['#ief_row_delta'],
  );
  return $remove_form;
}