BaseFieldDefinition setDisplayOptions ... type = 'string_textfield' ... unable to set default placeholder or size?

by Jack_Hu   Last Updated December 15, 2017 03:07 AM

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?'))
      ->setDefaultValue('')
      ->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.



Related Questions



How set a time type field programmatically?

Updated August 08, 2017 04:07 AM

Entities and Plugins. What's the relationship?

Updated June 28, 2017 15:07 PM

8 - Can I kint / ksm an entities plugin annotation?

Updated December 01, 2017 11:07 AM