1

I am trying to implement a base field with multiple selections as checkboxes I have had a go at implementing it but it stills appears as a select even after clearing the cache. I'm sure I'm doing this wrong but this is what I have:

$fields['content_display'] = BaseFieldDefinition::create('list_integer')
  ->setDisplayOptions('form', array(
    'type' => 'checkboxes',
    'weight' => -4,
  ))
  ->setSetting('allowed_values', $values)
  ->setDisplayConfigurable('form', TRUE);

1 Answer 1

5

Try with options_buttons because this is the ID if the OptionsButtonsWidget widget.

$fields['content_display'] = BaseFieldDefinition::create('list_integer')
  ->setDisplayOptions('form', array(
    'type' => 'options_buttons',
    'weight' => -4,
  ))
  ->setSetting('allowed_values', $values)
  ->setDisplayConfigurable('form', TRUE);
1
  • Great that worked just had to set my cardinality to unlimited
    – Mokugo
    Commented May 14, 2016 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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