You are here

function metatag_metatags_form_submit in Metatag 7

Form API submission callback.

Unset meta tag values that equal their default values, and load any additional meta tag values for other languages so that they can be properly saved later on.

See also

metatag_metatags_save()

1 call to metatag_metatags_form_submit()
metatag_commerce_product_form_submit in ./metatag.module
Form API submission callback for Commerce product.
1 string reference to 'metatag_metatags_form_submit'
metatag_metatags_form in ./metatag.module
Build a FAPI array for editing meta tags.

File

./metatag.module, line 1711
Primary hook implementations for Metatag.

Code

function metatag_metatags_form_submit($form, &$form_state) {
  if (!empty($form_state['values']['metatags'])) {

    // Unset meta tag values that equal their default values.
    foreach ($form_state['values']['metatags'] as $langcode => $values) {
      if (!empty($form['metatags'][$langcode]['#metatag_defaults'])) {
        metatag_filter_values_from_defaults($form_state['values']['metatags'][$langcode], $form['metatags'][$langcode]['#metatag_defaults']);
      }
    }

    // Need to load the entity's values for other languages, otherwise they will
    // be incorrectly deleted later on.
    if (isset($form['#entity']) && !empty($form['#entity']->metatags)) {
      foreach ($form['#entity']->metatags as $langcode => $values) {
        if (!isset($form_state['values']['metatags'][$langcode])) {
          $form_state['values']['metatags'][$langcode] = $values;
        }
      }
    }
  }
}