0

I've followed a tutorial here about adding a field to every taxonomy and node and I'm getting an error on installing it. I can get the field, widget and formatter to work, just can't get it to install.

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column [error]
'data.mix_page_load' in 'field list' in
/core/lib/Drupal/Core/Database/Statement.php:59

Can anyone knowledgable about this help? I don't want to use Field tools or ECK. I'm currently reading up on the Content Entity Field Definitions, but it's a lot of trial and error and no clear resolution yet.

The error only happens when I add this code to the mix_page_load.module

function mix_page_load_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'taxonomy_term' || $entity_type->id() === 'node') {
    $fields['mix_page_load'] = BaseFieldDefinition::create('mix_page_load')
      ->setLabel(t('Mixpanel Page Load'))
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
    return $fields;
  }
}

Here is the schema file

field.value.mix_page_load:
  type: mapping
  label: 'Default value'
  mapping:
    value:
      type: string
      label: 'Mixpanel Page Load'

Here is the DataType

namespace Drupal\mix_page_load\Plugin\DataType;

use Drupal\Core\TypedData\Plugin\DataType\StringData;
use Drupal\Core\TypedData\Type\StringInterface;

/**
 * The mix_page_load data type.
 *
 * The plain value of a MixPageLoadField for an entity.
 *
 * @DataType(
 *   id = "mix_page_load",
 *   label = @Translation("Mixpanel Page Load")
 * )
 */
class MixPageLoad extends StringData implements StringInterface {

}
  • field_mix_page_load and mix_page_load aren't the same thing (the field_ prefix is typically added by the Field UI module, base fields are just identified with what they're called); wherever you're using field_mix_page_load, change that to mix_page_load, rebuild caches, and try again – Clive Mar 19 at 15:28
  • Thanks so much for responding! I've edited the post, I think I pasted some old code I've been testing. I've got 'mix_page_load' on this module file and the DataType now, no reference to 'field_mix_page_load' anywhere and still getting the same error. – toomanychrises Mar 19 at 15:40
  • 1
    Have you run the entity updates to install the field? drush entup would be the quickest way – Clive Mar 19 at 15:42
  • I did not, and that fixed everything. Thank you sir, you are a magician. Clearly I still have a lot to learn, but hopefully this will help others who may venture down this path without all the knowledge. – toomanychrises Mar 19 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.