You are here

function schema_metatag_element_validate in Schema.org Metatag 7

Validation callback for a schema_metatag element to serialize nested arrays.

30 string references to 'schema_metatag_element_validate'
SchemaActionBase::getForm in src/SchemaActionBase.php
Build the form for this meta tag.
SchemaAddressBase::getForm in src/SchemaAddressBase.php
Build the form for this meta tag.
SchemaAnswerBase::getForm in src/SchemaAnswerBase.php
Build the form for this meta tag.
SchemaBrandBase::getForm in src/SchemaBrandBase.php
Build the form for this meta tag.
SchemaContactPointBase::getForm in src/SchemaContactPointBase.php
Build the form for this meta tag.

... See full list

File

./schema_metatag.module, line 39
Primary hook implementations for Schema.org Metatag.

Code

function schema_metatag_element_validate($element, &$form_state, $form) {

  // For values that are not string values but instead nested arrays,
  // serialize the results into a single string value.
  $keys = $element['#array_parents'];
  if (count($keys) >= 4) {
    if (isset($form_state['values'][$keys[0]][$keys[1]][$keys[3]][$keys[4]])) {
      $value = $form_state['values'][$keys[0]][$keys[1]][$keys[3]][$keys[4]];
      if (is_array($value)) {
        $value = SchemaMetatagManager::serialize($value);
        form_set_value($element, $value, $form_state);
      }
    }
  }
}