0

I am trying to display a dropdown where users can divide their article in a certain category. I have created a vocabulary called "category" and added s few fields to them.

I have added this to the content structure where the articles are defined. This works perfectly, however, the categories are not displayed as I desire:

enter image description here

When I inspect this element, there is a property used:

<select multiple="multiple">
    <option>...</option>
</select>

I don't want these options to be displayed together. I need a dropdown to let users select one of the categories.

I tried debugging and look for which html.twig file is being called, and tried to edit the select.html.twig but this did not solve the problem.

See select.html.twig

How can I get these options to show as a dropdown?

1 Answer 1

1

To get a taxonomy entity reference to show as a dropdown, there are two things you need to do.

  1. Go to the "manage form display" (admin/structure/types/manage/MY_CONTENT_TYPE/form-display) for your content type and make sure the Widget for the term field is set to Select list.

  2. Go to the "manage fields" for your content type and click "edit" for the entity reference for your terms. Go to the "Field settings" tab and make sure the Allowed number of values is 1. If this is set to 2 or more, Drupal will give you a multiple select, not a dropdown.

1
  • Had no idea it could be this simple. I did step one, but step 2 did the trick, thanks mate!!
    – Rubenxfd
    Sep 28, 2017 at 14:02

Your Answer

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

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