Sorry, if this is a duplicate

Here is the exact description of the problem:

I edit a term -> change metatag (title and description f.e.) -> save -> metags are changed (I can see the new ones) -> I edit the term again -> the metatags form is filled with default values (the new ones I typed in my first edit are lost) -> I save and I loose my metatag changes (I overwrite with default metatags).

Drupal version: 7.34
Metatag version: 7.x-1.4

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

I'm sorry you're having that problem with Metatag :( Can you please test if the patch in #2370439: Metatags data is not loaded in taxonomy term edit form and is not rendered in page html resolves the problem for you?

fox mulder’s picture

Hi Damien!

Thank you for quick response, but the patch not resolves the problem

DamienMcKenna’s picture

Can you please install & enable the Devel module and let me know what data is shown in the 'metatags' array?

fox mulder’s picture

metatags (Array, 1 element)
  und (Array, 1 element)
    title (Array, 1 element)
      value (String, 31 characters ) [term:name] | [site:name] | ccc

The value contains the string what I typed during the previous edit, and this value is saved in db. But when I reopen term to edit, the default value of Title input is: "[term:name] | [site:name]"

This value was added here: admin/config/search/metatags/config/taxonomy_term

DamienMcKenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
DamienMcKenna’s picture

Can you please test the patch in #2370439: Metatags data is not loaded in taxonomy term edit form and is not rendered in page html to see if it resolves the problem? Thanks.

fox mulder’s picture

I updated the metatag module to latest dev ( version: 7.x-1.4+21-dev ), but the updating still does not solve the problem

DamienMcKenna’s picture

Could you please provide me a list of modules currently in use on your site? Thanks.

fox mulder’s picture

Here is my list of enabled modules ( the output of drush pm-list --type=module --status=enabled ):
Package Name Version
Access control Taxonomy Access Control Lite (tac_lite) 7.x-1.2+1-dev
Administration Administration menu (admin_menu) 7.x-3.0-rc4+4-
dev
Administration Administration menu Toolbar style 7.x-3.0-rc4+4-
(admin_menu_toolbar) dev
Administration Administration views (admin_views) 7.x-1.3
Administration Module filter (module_filter) 7.x-2.0-alpha2
Chaos tool suite Chaos tools (ctools) 7.x-1.4+9-dev
Chaos tool suite Custom content panes (ctools_custom_content) 7.x-1.4+9-dev
Chaos tool suite Page manager (page_manager) 7.x-1.4+9-dev
Chaos tool suite Views content panes (views_content) 7.x-1.4+9-dev
Clientside Clientside Validation 7.x-1.41
Validation (clientside_validation)
Clientside Clientside Validation Form 7.x-1.41
Validation (clientside_validation_form)
Commerce Cart (commerce_cart) 7.x-1.10
Commerce Checkout (commerce_checkout) 7.x-1.10
Commerce Commerce (commerce) 7.x-1.10
Commerce Commerce Billy (commerce_billy) 7.x-1.0-beta2
Commerce Commerce Billy PDF (commerce_billy_pdf) 7.x-1.0-beta2
Commerce Commerce UI (commerce_ui) 7.x-1.10
Commerce Customer (commerce_customer) 7.x-1.10
Commerce Customer UI (commerce_customer_ui) 7.x-1.10
Commerce Line Item (commerce_line_item) 7.x-1.10
Commerce Line Item UI (commerce_line_item_ui) 7.x-1.10
Commerce Order (commerce_order) 7.x-1.10
Commerce Order UI (commerce_order_ui) 7.x-1.10
Commerce Payment (commerce_payment) 7.x-1.10
Commerce Payment UI (commerce_payment_ui) 7.x-1.10
Commerce Price (commerce_price) 7.x-1.10
Commerce Product (commerce_product) 7.x-1.10
Commerce Product Pricing (commerce_product_pricing) 7.x-1.10
Commerce Product Pricing UI 7.x-1.10
(commerce_product_pricing_ui)
Commerce Product Reference 7.x-1.10
(commerce_product_reference)
Commerce Product UI (commerce_product_ui) 7.x-1.10
Commerce Commerce Addressbook (commerce_addressbook) 7.x-2.0-rc8
(contrib)
Commerce Commerce Billy Mail (commerce_billy_mail) 7.x-1.0-beta3
(contrib)
Core Block (block) 7.34
Core Color (color) 7.34
Core Comment (comment) 7.34
Core Content translation (translation) 7.34
Core Contextual links (contextual) 7.34
Core Dashboard (dashboard) 7.34
Core Database logging (dblog) 7.34
Core Field (field) 7.34
Core Field SQL storage (field_sql_storage) 7.34
Core Field UI (field_ui) 7.34
Core File (file) 7.34
Core Filter (filter) 7.34
Core Help (help) 7.34
Core Image (image) 7.34
Core List (list) 7.34
Core Locale (locale) 7.34
Core Menu (menu) 7.34
Core Node (node) 7.34
Core Number (number) 7.34
Core Options (options) 7.34
Core Overlay (overlay) 7.34
Core Path (path) 7.34
Core RDF (rdf) 7.34
Core Shortcut (shortcut) 7.34
Core System (system) 7.34
Core Taxonomy (taxonomy) 7.34
Core Text (text) 7.34
Core Trigger (trigger) 7.34
Core Update manager (update) 7.34
Core User (user) 7.34
Date/Time Date (date) 7.x-2.8
Date/Time Date API (date_api) 7.x-2.8
Development Devel (devel) 7.x-1.5
Display Suite Display Suite (ds) 7.x-2.7
Display Suite Display Suite UI (ds_ui) 7.x-2.7
Entityforms Entityforms (entityform) 7.x-2.0-rc1
FAQ faq_content (faq_content) 7.x-2.0-alpha2
FAQ faq_expert (faq_expert) 7.x-2.0-alpha2
FAQ Frequently Asked Questions (faq) 7.x-2.0-alpha2
Features Features (features) 7.x-2.2
Features Features Diff (features_diff) 7.x-1.0-beta1
Fields Address Field (addressfield) 7.x-1.0-beta5
Fields Email (email) 7.x-1.3
Fields Field Permissions (field_permissions) 7.x-1.0-beta2
Fields File Field Sources (filefield_sources) 7.x-1.9
Fields Telephone (telephone) 7.x-1.0-alpha1
Fields Title (title) 7.x-1.0-alpha7
+10-dev
Flags Flag (flag) 7.x-3.5
FlexSlider FlexSlider (flexslider) 7.x-2.0-alpha3
FlexSlider FlexSlider Views Style (flexslider_views) 7.x-2.0-alpha3
Form Elements Hierarchical Select (hierarchical_select) 7.x-3.0-alpha6
Form Elements Hierarchical Select Taxonomy (hs_taxonomy) 7.x-3.0-alpha6
Input filters Pathologic (pathologic) 7.x-3.0-beta2
Input filters SpamSpan (spamspan) 7.x-1.1-beta7
Mail Mail System (mailsystem) 7.x-2.34
Mail Mime Mail (mimemail) 7.x-1.0-beta3+
13-dev
Mail Mime Mail Action (mimemail_action) 7.x-1.0-beta3+
13-dev
Mail Mime Mail CSS Compressor (mimemail_compress) 7.x-1.0-beta3+
13-dev
Media IMCE (imce) 7.x-1.9
Multilanguage MultiLink (multilink) 7.x-2.10
Multilingual Localization client (l10n_client) 7.x-1.3
Multilingual Localization update (l10n_update) 7.x-1.1
Multilingual - Field translation (i18n_field) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Internationalization (i18n) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Multilingual content (i18n_node) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Multilingual select (i18n_select) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Panels translation (i18n_panels) 7.x-3.4
Internationaliza
tion
Multilingual - String translation (i18n_string) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Taxonomy translation (i18n_taxonomy) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Translation sets (i18n_translation) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Variable translation (i18n_variable) 7.x-1.11+8-dev
Internationaliza
tion
Multilingual - Views translation (i18nviews) 7.x-3.x-dev
Internationaliza
tion
Other Absolute Messages (absolute_messages) 7.x-1.3+13-dev
Other Backup and Migrate (backup_migrate) 7.x-3.0
Other Backup and migrate prune 7.x-2.0-beta1
(backup_migrate_prune)
Other Better Formats (better_formats) 7.x-1.0-beta1
Other Diff (diff) 7.x-3.2+20-dev
Other Disable Password Strength Check 7.x-1.1+0-dev
(disablepwstrength)
Other Entity API (entity) 7.x-1.5
Other Entity Delete Log (entity_delete_log) 7.x-1.1+2-dev
Other Entity tokens (entity_token) 7.x-1.5
Other Environment indicator 7.x-2.5
(environment_indicator)
Other Feedback Simple (feedback_simple) 7.x-1.6+2-dev
Other Flood unblock (flood_unblock) 7.x-1.4
Other Form block (formblock) 7.x-1.0-alpha1
Other Hide submit button (hide_submit) 7.x-2.0+1-dev
Other Libraries (libraries) 7.x-2.2
Other Link checker (linkchecker) 7.x-1.2
Other Linkit (linkit) 7.x-3.2
Other Login Destination (login_destination) 7.x-1.1+0-dev
Other LoginToboggan (logintoboggan) 7.x-1.4
Other Masquerade (masquerade) 7.x-1.0-rc7
Other Menu Block (menu_block) 7.x-2.4
Other Parallax Background (parallax_bg) 7.x-1.2
Other Pathauto (pathauto) 7.x-1.2
Other Rabbit Hole (rabbit_hole) 7.x-2.23
Other Rabbit Hole nodes (rh_node) 7.x-2.23
Other Redirect (redirect) 7.x-1.0-rc1+6-
dev
Other Session Limit (session_limit) 7.x-2.0
Other simplehtmldom API (simplehtmldom) 7.x-2.1
Other Strongarm (strongarm) 7.x-2.0+2-dev
Other Theme Test (themetest) 7.x-1.0
Other Token (token) 7.x-1.5
Other Transliteration (transliteration) 7.x-3.2
Owl Carousel Owl Carousel (owlcarousel) 7.x-1.2
Owl Carousel Owl Carousel UI (owlcarousel_ui) 7.x-1.2
Owl Carousel Owl Carousel Views (owlcarousel_views) 7.x-1.2
Panels Mini panels (panels_mini) 7.x-3.4
Panels Panels (panels) 7.x-3.4
Panels Panels everywhere (panels_everywhere) 7.x-1.0-rc1
Path management Global Redirect (globalredirect) 7.x-1.5+3-dev
Performance and Memcache (memcache) 7.x-1.0
scalability
Rules Rules (rules) 7.x-2.7
Rules Rules Session Vars (rules_session_vars) 7.x-1.0
Rules Rules UI (rules_admin) 7.x-2.7
Rules TACLe Rules (tacle_rules) 7.x-1.0-beta1
Search Database search (search_api_db) 7.x-1.4
Search Search API (search_api) 7.x-1.13
Search Search views (search_api_views) 7.x-1.13
SEO Metatag (metatag) 7.x-1.4+21-dev
SEO Metatag:OpenGraph (metatag_opengraph) 7.x-1.4+21-dev
Spam control CAPTCHA (captcha) 7.x-1.1
Spam control Honeypot (honeypot) 7.x-1.17
Spam control Image CAPTCHA (image_captcha) 7.x-1.1
Spam control Math CAPTCHA (math_captcha) 7.x-1.0-alpha1
Spam control reCAPTCHA (recaptcha) 7.x-1.11
Statistics Google Analytics (googleanalytics) 7.x-2.0
Taxonomy Taxonomy Manager (taxonomy_manager) 7.x-1.0
Taxonomy menu Taxonomy menu (taxonomy_menu) 7.x-1.5
User interface CKEditor (ckeditor) 7.x-1.16
User interface Compact Forms (compact_forms) 7.x-1.0
User interface jQuery Update (jquery_update) 7.x-2.4+5-dev
Variable Variable (variable) 7.x-2.5
Variable Variable realm (variable_realm) 7.x-2.5
Variable Variable store (variable_store) 7.x-2.5
Views Draggableviews (draggableviews) 7.x-2.0+56-dev
Views Views (views) 7.x-3.8
Views Views Bulk Operations 7.x-3.2
(views_bulk_operations)
Views Views Isotope (views_isotope) 7.x-2.0-alpha1
Views Views Slideshow (views_slideshow) 7.x-3.1
Views Views Slideshow: Cycle 7.x-3.1
(views_slideshow_cycle)
Views Views UI (views_ui) 7.x-3.8
XML sitemap XML sitemap (xmlsitemap) 7.x-2.0
XML sitemap XML sitemap engines (xmlsitemap_engines) 7.x-2.0
XML sitemap XML sitemap internationalization 7.x-2.0
(xmlsitemap_i18n)
XML sitemap XML sitemap node (xmlsitemap_node) 7.x-2.0
XML sitemap XML sitemap taxonomy (xmlsitemap_taxonomy) 7.x-2.0

DamienMcKenna’s picture

Please try the latest -dev snapshot (7.x-1.4+24-dev) and let me know if it solves the problem.

betz’s picture

Status: Active » Needs review

I have a feeling that the patch at #2411477: Metatags $form['#entity'] in metatag_metatags_form not set, uses entity 'token type'. also will solve this problem.
If someone can test, it needs a review...
So setting this issue also to review ;)

DamienMcKenna’s picture

DamienMcKenna’s picture

I believe this may have been resolved by #2411477: Metatags $form['#entity'] in metatag_metatags_form not set, uses entity 'token type'., would you mind testing the latest dev snapshot?

DamienMcKenna’s picture

Component: Other tags » Code
fox mulder’s picture

Sorry but the problem still persists.

I updated to the latest dev ( 7.x-1.5-beta1+0-dev ), but there is no change

fox mulder’s picture

FileSize
87.29 KB

I think I found something that can help...

In metatag.module the metatag_form_alter() function calls metatag_metatags_form(array &$form, $instance, array $metatags = array(), array $options = array()) function.

I added some dsm() calls to this functions:

function metatag_form_alter(&$form, $form_state, $form_id) {
  if (!empty($form['#metatags']) && !isset($form['metatags'])) {
    extract($form['#metatags']);
    dsm($metatags, 'metatag_form_alter()');  // dsm()
    metatag_metatags_form($form, $instance, $metatags, $options);
    unset($form['#metatags']);
  }
} 

and

...
// Build the form for each metatag.
  foreach ($info['tags'] as $metatag => $metatag_info) {
    // @todo Replace context matching with hook_metatag_access().
    if (isset($options['context']) && isset($metatag_info['context'])) {
      if (!in_array($options['context'], $metatag_info['context'])) {
        continue;
      }
    }
    if ($metatag == 'keywords') dsm($metatags, 'metatag_metatags_form()'); // <--- dsm()
    $metatag_instance = metatag_get_instance($metatag, isset($metatags[$metatag]) ? $metatags[$metatag] : array());
    if (empty($metatag_instance)) {
      continue;
    }

    // Get the form element from the meta tag class.
    $metatag_form = $metatag_instance->getForm($options);
    ...

If I filled in the keywords metatag on taxonomy/term/N/edit page, save it, and than reopen the edit page than the dsm() calls print out some infos ( see image ) and it appears that in line $metatag_instance = metatag_get_instance($metatag, isset($metatags[$metatag]) ? $metatags[$metatag] : array()); the metatag_get_instance() is called with an empty array as second parameter, because $metatags['keywords'] does not exists, but $metatags['und']['keywords'] does.

Because the $data array in metatag_get_instance() function is empty, than in the DrupalTextMetaTag->getForm() function the '#default_value' FAPI element will be an empty string

class DrupalTextMetaTag extends DrupalDefaultMetaTag {

  public function getForm(array $options = array()) {
    $options += array(
      'token types' => array(),
    );

    $form['value'] = isset($this->info['form']) ? $this->info['form'] : array();

    $form['value'] += array(
      '#type' => 'textfield',
      '#title' => $this->info['label'],
      '#description' => !empty($this->info['description']) ? $this->info['description'] : '',
      '#default_value' => isset($this->data['value']) ? $this->data['value'] : '',  // <--- empty string
      '#element_validate' => array('token_element_validate'),
      '#token_types' => $options['token types'],
      '#maxlength' => 1024,
    ); 
DamienMcKenna’s picture

Status: Postponed » Active

@fox mulder: After you save the values the first time, do they show up correctly on the term page? What does it look like when you load up the Devel tab on the term?

fox mulder’s picture

The values are saved. If I view the term page, the saved values are in the HTML source, and on Devel tab

DamienMcKenna’s picture

@fox mulder: Can you please upload a screenshot of what Devel shows for the $term->metatag structure? That'll help. Thanks.

fox mulder’s picture

Here is the devel ( load )output

benjifisher’s picture

I think I ran into the same bug. I am using the Migrate module to create nodes with metatag fields. The title and keywords worked fine, but the description did not. Once I found this issue, I checked the devel tab, and I realized that the description was there, just not showing up on the node-edit page, which is where I had been looking. The description is configured with a default value.

The devel tab shows this:

metatags (Array, 3 elements)

    title (Array, 1 element)
        value (Array, 1 element)
            0 (String, 52 characters ) Text snipped to avoid identifying the site...
    keywords (Array, 1 element)
        value (Array, 1 element)
            0 (String, 102 characters ) term1, term2, term3, t...
    description (Array, 1 element)
        value (Array, 1 element)
            0 (String, 48 characters ) Text snipped to avoid identifying the site.

benjifisher’s picture

I implemented hook_form_alter() with the line

  $form['metatags']['und']['description']['value']['#type'] = 'textfield';

and suddenly my values appear. So something is messing with textareas but not textfields.

benjifisher’s picture

Sorry for the noise. After digging into it further, I found that my problems are caused by #2411549: Language is missing in metatag structure during migration and not this issue.

LiamPower’s picture

Having a similar issue as this, but when the term is created with metatags when I go back in to edit the term the defaults are shown. Upon inspecting with Devel the metatags array has 0 elements in it. If I edit the metatags again and save they will then save. It's just on the initial save of the taxonomy term where the metatags visible in the term when re-editing.

They do show on the front end after term creation though

DamienMcKenna’s picture

Could everyone please try the current -dev release and let me know if the problem persists? Thanks!

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)
Parent issue: #2376921: META: Plan for Metatag 7.x-1.5 release »
LiamPower’s picture

Status: Postponed (maintainer needs more info) » Needs work

Still having the same issue.

LiamPower’s picture

I believe the issue I'm having is an issue between the Metatags and Taxonomy Revision modules as I disabled the Taxonomy Revision module and created a new term. The metatags saved this time.

Not sure who's module would be best to patch at the moment

DamienMcKenna’s picture

@LiamPower: Thanks for helping to track that down. I've spun off a new issue for this: #2501005: Revision ID should default to entity ID

DamienMcKenna’s picture

Title: metatags on taxonomy term edit page are saved, but if reopen it to edit, the metatags form is filled with default values » Ensure module works with i18n_taxonomy

I wonder if the problem is i18n_taxonomy? It seems likely. Lets focus there.

DamienMcKenna’s picture

Component: Code » Multilingual/intl
DamienMcKenna’s picture

Status: Needs work » Closed (cannot reproduce)

We've greatly expanded the test coverage on the module and OOTB terms work fine, please open another issue if you have a problem with terms besides the Taxonomy Revision issue that'll be handled in #2501005: Revision ID should default to entity ID.