3

I have displayed an admin form using UiComponent form. As one of my admin field I want to display all store views in a multi-select field.

Please help me with a solution.

1

1 Answer 1

11

Add following code into your ui_component form

<field name="storeviews">
    <argument name="data" xsi:type="array">
        <item name="options" xsi:type="object">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</item>
        <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">int</item>
            <item name="label" xsi:type="string" translate="true">Store View</item>
            <item name="formElement" xsi:type="string">multiselect</item>
            <item name="source" xsi:type="string">page</item>
            <item name="dataScope" xsi:type="string">store_id</item>
            <item name="default" xsi:type="string">0</item>
            <item name="validation" xsi:type="array">
                <item name="required-entry" xsi:type="boolean">true</item>
            </item>
        </item>
    </argument>
</field>
2
  • Thank you. It worked .But just need to end tag item in line 3 Commented Jan 13, 2017 at 7:56
  • I just updated, check now. Commented Jan 13, 2017 at 8:04

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.