I'm unable to get a default placeholder and/or size to register against a BaseFieldDefinition. I'm trying something like:

$fields['company_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Company Name'))
      ->setDescription(t('What\'s your company called?'))
      ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'settings' => [
          'display_label' => TRUE,
          'size' => 10,
          'placeholder' => '',
        'weight' => '9',
      ->setDisplayConfigurable('form', TRUE);

But when I enable my module, and check the 'Manage Form Display' tab for the relevant entity, it shows the defaults (size = 60, placeholder = {null}).

Does anyone know how to get these working..? Especially the placeholder one.


I think you need to be calling "setSettings" on the field, not passing the settings as a part of the display options.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.