S
S
semki0962019-04-23 10:32:50
Twig
semki096, 2019-04-23 10:32:50

How to edit selected values ​​in a multiselect?

There is a form for editing a product with a drop-down list:

<select>
    <option>Фиолетовый</option>
    <option>Белый</option>
    ....
    <option>Зелёный</option>
</select>

I need to substitute selected for the colors that are present in the product object, I can display them like this (twig)
{% for color in product.colors %}
         {{ color.name }}
{% endfor %}

But I can't figure out how to add the selected option to the desired color in the list. I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Perin, 2019-04-23
@seoperin

<select>
{% for color in product.colors %}
         <option value="{{ color.id }}">{{ color.name }}</option>
{% endfor %}
</select>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question