You are here

function acquia_lift_element_variation_delete_form in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift.admin.unibar.inc \acquia_lift_element_variation_delete_form()

Form handler to generate a confirmation form to delete an element variation.

This form is called within a ctools modal window.

Parameters

string $agent_name: The name of the campaign to edit.

int $osid: The id of the option set

string $option_id: The id of the option/variation.

1 string reference to 'acquia_lift_element_variation_delete_form'
acquia_lift_element_variation_delete_modal_callback in ./acquia_lift.admin.unibar.inc
Page callback to generate an element variation delete confirm modal window.

File

./acquia_lift.admin.unibar.inc, line 486
acquia_lift.admin.unibar.inc

Code

function acquia_lift_element_variation_delete_form($form, &$form_state, $osid, $option_id) {
  ctools_include('modal');
  ctools_include('ajax');
  ctools_add_js('ajax-responder');
  $option_set = personalize_option_set_load($osid);
  $variation_name = $option_id;
  foreach ($option_set->options as $option) {
    if ($option['option_id'] === $option_id) {
      $variation_name = $option['option_label'];
      break;
    }
  }
  $form = array();
  $form['agent_name'] = array(
    '#type' => 'value',
    '#value' => $option_set->agent,
  );
  $form['option_set'] = array(
    '#type' => 'value',
    '#value' => $option_set,
  );
  $form['option_id'] = array(
    '#type' => 'value',
    '#value' => $option_id,
  );
  if ($option_id == PERSONALIZE_CONTROL_OPTION_ID) {
    $form['message'] = array(
      '#markup' => t('The control variation cannot be renamed.'),
    );
    return $form;
  }
  $form['confirm'] = array(
    '#prefix' => '<div>',
    '#suffix' => '</div>',
    '#markup' => t('Are you sure you want to delete %variation?', array(
      '%variation' => $variation_name,
    )),
  );
  $form['actions']['submit_form'] = array(
    '#type' => 'submit',
    '#attributes' => array(
      'class' => array(
        'action-item-primary-active',
        'acquia-lift-submit-button',
      ),
    ),
    '#value' => t('Delete'),
  );
  $form['actions']['reset'] = array(
    '#markup' => ctools_ajax_text_button(t('Cancel'), 'admin/structure/acquia_lift/cancel/nojs', t('Cancel'), 'acquia-lift-cancel-button'),
  );
  return $form;
}