You are here

function yoast_seo_configuration_form_submit in Real-time SEO for Drupal 7

Form API submission callback.

Moving submitted values back into the metatag fields.

1 string reference to 'yoast_seo_configuration_form_submit'
yoast_seo_configuration_form in ./yoast_seo.module
Build a FAPI array for editing meta tags.

File

./yoast_seo.module, line 214
Primary hook implementations for Yoast SEO for Drupal module.

Code

function yoast_seo_configuration_form_submit($form, &$form_state) {
  if (!empty($form_state['values']['metatags'])) {
    $langcode = $form_state['values']['language'];

    // Moving the title field value.
    if (isset($form_state['values']['metatags'][$langcode]['title']['value']) && isset($form_state['values']['metatags'][$langcode]['title']['default'])) {
      $title = trim($form_state['values']['metatags'][$langcode]['title']['value']);

      // If the title is the placeholder we had before, we would like to replace
      // it with Metatag defaults.
      if (empty($title)) {
        $form_state['values']['metatags'][$langcode]['title']['value'] = $form_state['values']['metatags'][$langcode]['title']['default'];
      }
    }

    // Moving the description field value.
    if (isset($form_state['values']['metatags'][$langcode]['description']['value']) && isset($form_state['values']['metatags'][$langcode]['description']['default'])) {
      $description = trim($form_state['values']['metatags'][$langcode]['description']['value']);

      // If the description is the placeholder we had before, we would like to
      // replace it with Metatag defaults.
      if (empty($description)) {
        $form_state['values']['metatags'][$langcode]['description']['value'] = $form_state['values']['metatags'][$langcode]['description']['default'];
      }
    }
  }
}