You are here

public function CvWebformValidationSomeOfSeveralValidator::getJavascriptSettings in Clientside Validation 7.2

Overrides CvWebformValidationValidator::getJavascriptSettings

File

clientside_validation_webform_validation/plugins/validator/webformvalidationsomeofseveral.inc, line 17

Class

CvWebformValidationSomeOfSeveralValidator

Code

public function getJavascriptSettings(array &$element, array &$form_state) {
  $rule = _clientside_validation_get_webform_validation_rules($element, $form_state['complete form'], $this->webform_rule);
  ksort($rule['components']);
  $firstone = reset($rule['components']);
  $name = $this
    ->getName($element);
  $names = array();
  $group_names = array();
  $group = $firstone['element_name'] . '_group';
  $element['#cv_data']['rule'] = $rule;
  foreach ($rule['components'] as $component) {
    $names[] = ':input[name="' . $component['element_name'] . '"]';
    $group_names[] = $component['element_name'];
  }
  return array(
    'rules' => array(
      $name => array(
        $this->js_rule => array(
          isset($rule['data']) ? (int) $rule['data'] : 1,
          implode(', ', $names),
        ),
      ),
    ),
    'messages' => array(
      $name => array(
        $this->js_rule => $this
          ->getMessage($element),
      ),
    ),
    'groups' => array(
      $group => $group_names,
    ),
  );
}