Simple multiple select generated by custom entity form. See attached image.

This is the BaseFieldDefinition to replicate.

    $fields['country'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Countries'))
      ->setDescription(t('Countries of this fee'))
      ->setSetting('target_type', 'country')
      ->setSetting('handler', 'default')
      ->setRequired(true)
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE)
      ->setDisplayOptions('form', [
        'type' => 'options_select',
      ]);

(Replace country target_type with "user", for example)

Comments

estoyausente created an issue. See original summary.

markhalliwell’s picture

Ah, that is indeed not good. I would say that we should just expand the CSS to include :not([multiple]), but perhaps we should just remove the wrapper from the template entirely if multiple?

grimreaper’s picture

Status: Active » Needs review
StatusFileSize
new3.04 KB

Hello,

As there is no mean to affect the parent styling based on the children in CSS (maybe I missed a way), here is a patch that removed the wrapper.

I think it would have been better to keep the wrapper but that would have required JS.

Thanks for the review.

markhalliwell’s picture

Status: Needs review » Needs work

Instead of adding a whole new template, I'd rather we extract and determine if the multiple attribute is set and just throw the wrapper in an if statement.

grimreaper’s picture

Status: Needs work » Needs review
StatusFileSize
new1.17 KB

Ok. Here comes the patch.

Thanks for the review.

jorgediazhav’s picture

Component: CSS Overrides » Templates
Status: Needs review » Reviewed & tested by the community

Yep. Works great.

I tested it with:
- Unlimited Selection
- Limited above +2.
- Limited selection set to 1 rolls back to the normal select.

  • markcarver committed 90ae3e4 on 8.x-3.x authored by Grimreaper
    Issue #2762091 by Grimreaper, estoyausente: Select multiple field has an...
markhalliwell’s picture

Status: Reviewed & tested by the community » Fixed

Awesome! Thanks @Grimreaper!

grimreaper’s picture

Thanks for the commits (of other issues too) :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.