Question

UI component xml

    <field name="notification_deal_type">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">Embitel\PushNotification\Model\DealType\Source\DealType</item>
            <item name="config" xsi:type="array">                    
                <item name="sortOrder" xsi:type="number">1</item>
                <item name="dataType" xsi:type="string">text</item>

                <item name="formElement" xsi:type="string">radioset</item>

                <item name="label" xsi:type="string" translate="true">Deal Type</item>
                <item name="prefer" xsi:type="string">toggle</item>
                <item name="valueMap" xsi:type="array">
                    <item name="true" xsi:type="number">1</item>
                    <item name="false" xsi:type="number">0</item>
                </item>
                <item name="default" xsi:type="number">0</item>
                <item name="source" xsi:type="string">pushnotification</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
        <settings>
            <switcherConfig>
                <rules>
                    <rule name="0">
                        <value>1</value>
                        <actions>
                            <action name="0">
                                <target>pushnotification_index_form.pushnotification_index_form.pushnotification.notification_city</target>
                                <callback>show</callback>
                            </action>
                            <action name="1">
                                <target>pushnotification_index_form.pushnotification_index_form.pushnotification.deal_title</target>
                                <callback>hide</callback>
                            </action>
                        </actions>
                    </rule>
                    <rule name="1">
                        <value>0</value>
                        <actions>
                            <action name="0">
                                <target>pushnotification_index_form.pushnotification_index_form.pushnotification.notification_city</target>
                                <callback>hide</callback>
                            </action>
                            <action name="1">
                                <target>pushnotification_index_form.pushnotification_index_form.pushnotification.deal_title</target>
                                <callback>show</callback>
                            </action>
                        </actions>
                    </rule>
                </rules>
                <enabled>true</enabled>
            </switcherConfig>
            <dataType>number</dataType>
            <dataScope>notification_deal_type</dataScope>
        </settings>
    </field>

Model option

namespace Embitel\PushNotification\Model\DealType\Source;

use Magento\Framework\Data\OptionSourceInterface;

/**
 * Class Status
 */
class DealType implements OptionSourceInterface {

    /**
     * Get options
     *
     * @return array
     */
    public function toOptionArray() {
        $availableOptions = ['1' => 'Planned Deal', '0' => 'Running Deal'];
        $options = [];
        $i = 0;
        foreach ($availableOptions as $key => $label) {
            $options[] = [
                'label' => $label,
                'value' => $key
            ];
            $i++;
        }
        return $options;
    }

}

I want planned deal is default deal.

No correct solution

OTHER TIPS

Change

<item name="default" xsi:type="number">0</item>

to

<item name="default" xsi:type="number">1</item>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top