You are here

public static function AcquiaLiftAgent::optionsFormValidate in Acquia Lift Connector 7

Implements PersonalizeAgentInterface::optionsFormValidate().

File

plugins/agent_types/AcquiaLiftAgent.inc, line 426
Provides an agent type for Acquia Lift

Class

AcquiaLiftAgent

Code

public static function optionsFormValidate($form, &$form_state, $option_parents = array()) {
  $values =& $form_state['values'];
  foreach ($option_parents as $parent) {
    $values =& $values[$parent];
  }
  $error_parents = implode('][', $option_parents);
  if (isset($values['control_rate'])) {
    $rate = $values['control_rate'];
    if (!is_numeric($rate) || !($rate >= 0 && $rate <= 100)) {
      $error_element = empty($error_parents) ? 'control_rate' : $error_parents . '][contral_rate';
      form_set_error($error_element, t('Invalid percent to test specified'));
    }
  }
  if (isset($values['explore_rate'])) {
    $rate = $values['explore_rate'];
    if (!is_numeric($rate) || !($rate >= 0 && $rate <= 100)) {
      $error_element = empty($error_parents) ? 'explore_rate' : $error_parents . '][explore_rate';
      form_set_error($error_element, t('Invalid percent to test specified'));
    }
  }

  // If "Run until a winner is found" was selected, we need to add this to the agent's
  // data property.
  if (isset($form_state['values']['campaign_end']) && $form_state['values']['campaign_end'] == 'auto') {
    $values['auto_stop'] = 1;
  }
}