You are here

function googleanalytics_validate_create_field_values in Google Analytics 6.4

Same name and namespace in other branches
  1. 7.2 googleanalytics.admin.inc \googleanalytics_validate_create_field_values()

#element_validate callback for create only fields.

Parameters

$element: An associative array containing the properties and children of the generic form element.

$form_state: The $form_state array for the form this element belongs to.

See also

form_process_pattern()

1 string reference to 'googleanalytics_validate_create_field_values'
googleanalytics_admin_settings_form in ./googleanalytics.admin.inc
Implementation of hook_admin_settings() for module settings configuration.

File

./googleanalytics.admin.inc, line 687
Administrative page callbacks for the googleanalytics module.

Code

function googleanalytics_validate_create_field_values(&$element, &$form_state) {
  $values = _googleanalytics_extract_create_field_values($element['#value']);
  if (!is_array($values)) {
    form_error($element, t('The %element-title field contains invalid input.', array(
      '%element-title' => $element['#title'],
    )));
  }
  else {

    // Check that name and value are valid for the field type.
    foreach ($values as $name => $value) {
      if ($error = _googleanalytics_validate_create_field_name($name)) {
        form_error($element, $error);
        break;
      }
      if ($error = _googleanalytics_validate_create_field_value($value)) {
        form_error($element, $error);
        break;
      }
    }
    return $element;
  }
}