You are here

function _acquia_lift_page_variation_details_form_submit in Acquia Lift Connector 7

Submit handler to create a new page variation for an AB agent.

This creates a page variation set if it does not yet exist and the variation for that page. For a simple A/B test, there is only a single variation set allowed per campaign and therefore it is named for the campaign/agent.

A variation set is similar to a decision name concept and groups together option sets for a particular agent to be considered as a group. A variation is comprised of all of the options of the same index across all option sets in a variation set (decision name). In other words, an option set handles the changes for a single element of the variation and includes how that element is shown for each variation as its options.

1 call to _acquia_lift_page_variation_details_form_submit()
acquia_lift_element_variation_details_form_submit in ./acquia_lift.admin.unibar.inc
Form submit handler for acquia_lift_element_variation_details_form.

File

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

Code

function _acquia_lift_page_variation_details_form_submit($form, &$form_state) {
  $agent_name = $variation_set_name = $form_state['values']['agent'];
  $option_set = personalize_elements_get_option_set_for_variation($variation_set_name, $agent_name, $form_state['values']['selector'], $form_state['values']['variation_type'], $form_state['values']['pages']);
  $variation_number = NULL;
  if (is_numeric($form_state['values']['variation_number']) && $form_state['values']['variation_number'] >= 0) {
    $variation_number = $form_state['values']['variation_number'];
  }
  module_load_include('inc', 'acquia_lift', 'acquia_lift.page_variations');
  $variation_number = acquia_lift_page_variation_create($variation_set_name, $option_set, array(
    'personalize_elements_content' => $form_state['values']['personalize_elements_content'],
  ), $variation_number);

  // Save the updated option sets for use within the Ajax callback.
  $form_state['storage']['option_sets'] = personalize_option_set_load_multiple(FALSE, array(
    'decision_name' => $variation_set_name,
  ));
  $form_state['storage']['variation_number'] = $variation_number;
  $form_state['storage']['confirmation_message'] = t('The variation has been created.');
}