You are here

function _acquia_lift_existing_goal_create_form in Acquia Lift Connector 7.2

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

Loads the existing goal selection form for a campaign.

Parameters

$agent: The agent data for the campaign that this goal will belong to.

2 calls to _acquia_lift_existing_goal_create_form()
acquia_lift_goal_type_create_form in ./acquia_lift.admin.unibar.inc
Form builder function to create a new goal in the modal process of a specific type.
acquia_lift_personalize_campaign_wizard_goals_alter in ./acquia_lift.admin.wizard.inc
Alter the goals form.

File

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

Code

function _acquia_lift_existing_goal_create_form($agent) {

  // Exclude any actions already used in this campaign.
  $exclude = array();
  $goals = personalize_goal_load_by_conditions(array(
    'agent' => $agent->machine_name,
  ));
  foreach ($goals as $goal) {
    $exclude[$goal->action] = $goal->action;
  }
  module_load_include('inc', 'personalize', 'personalize.admin');
  $all_goal_options = personalize_goals_options(TRUE);
  $goal_options = array_diff_key($all_goal_options, $exclude);
  $form['action_name'] = array(
    '#type' => 'select',
    '#title' => t('Goal'),
    '#options' => $goal_options,
    '#empty_option' => t('-Select-'),
    '#required' => TRUE,
  );
  return $form;
}