- Issue created by @SAHIL ROHILLA01
- 🇺🇸United States DamienMcKenna NH, USA
Just to confirm it - you have a fieldable entity type, you added a Metatag field to it, when editing or creating an entity you filled in that field but you don't see any values stored in the database for that field? And you also had a default configuration created?
Did you change the default values when you filled in the entity values? Metatag only stores values that were different from the default values, so if you didn't change anything then there wouldn't be anything stored in the database, by design.
You might try using metatag_generate_entity_all_tags($entity); to see what the module wants to generate for it.
- 🇮🇳India SAHIL ROHILLA01
@DameinMckenna , yes i had set a default value in meta config but after that no data has been stored in db and after that i have changed default value during node create or update then data was stored in field_metatag column in db and i had written below code for metatag field and i had also tried metatag field using ui but i had found metatag module was not working proper for custom entity
$fields['field_metatag'] = BaseFieldDefinition::create('metatag')
->setLabel(t('Metatag'))
->setDescription(t('The metatag field for your custom entity.'))
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'metatag_empty_formatter',
'weight' => 6,
])
->setDisplayOptions('form', [
'type' => 'metatag_default',
'weight' => 6,
])
->setDisplayConfigurable('form', TRUE)
->setTranslatable(TRUE)
->setDisplayConfigurable('view', TRUE); - 🇺🇸United States DamienMcKenna NH, USA
I haven't tried out doing it that way, so it's possible there might be something missing somewhere. I honestly don't know off-hand, sorry.
I think it'd be worth starting to fix this by building a simple entity type and testing it
- 🇮🇳India SAHIL ROHILLA01
@DamienMcKenna , this issue is only coming in drupal console custom entity (drupal generate:entity:content)
& not in drush custom entity (drush generate module-content-entity), thanks - 🇺🇸United States DamienMcKenna NH, USA
Can you please compare the entity annotations to see what is different about them?