0

How can I add some static dropdown option in admin from by uiComponent.

I am using this but it's not working.

        <field name="gender">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">
                    <item value="0" xsi:type="string">Doesn't Matter</item>
                    <item value="1" xsi:type="string">Male</item>
                    <item value="2" xsi:type="string">Female</item>
                </item>
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Gender</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="dataType" xsi:type="string">number</item>
                    <item name="formElement" xsi:type="string">select</item>
                    <item name="source" xsi:type="string">job</item>
                    <item name="dataScope" xsi:type="string">gender</item>
                    <item name="sortOrder" xsi:type="number">60</item>
                </item>
            </argument>
        </field>

1 Answer 1

4

Replace your options item with

           <item name="options" xsi:type="array">
                <item name="0" xsi:type="array">
                    <item name="value" xsi:type="number">0</item>
                    <item name="label" xsi:type="string" translate="true">Doesn't Matter</item>
                </item>
                <item name="1" xsi:type="array">
                    <item name="value" xsi:type="number">1</item>
                    <item name="label" xsi:type="string" translate="true">Male</item>
                </item>
                <item name="2" xsi:type="array">
                    <item name="value" xsi:type="number">2</item>
                    <item name="label" xsi:type="string" translate="true">Female</item>
                </item>
            </item>

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.