1

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.

1

Change

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

to

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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