How can i change Yes to Active and No to Deactive?


i've tried it with toOptionArray():

class ActiveDeactive implements \Magento\Framework\Option\ArrayInterface
    public function toOptionArray()
        return [
            'value' => 'Active',
            'value_another' => 'Deactive'

and with xml:

<field name="status">
    <argument name="data" xsi:type="array">
       <item name="config" xsi:type="array">
            <item name="dataType" xsi:type="string">boolean</item>
                 <item name="label" xsi:type="string" translate="true">Status</item>
                 <item name="formElement" xsi:type="string">checkbox</item>
                 <item name="source" xsi:type="string">pricelist</item>
                 <item name="dataScope" xsi:type="string">status</item>
                 <item name="prefer" xsi:type="string">toggle</item>
                 <item name="valueMap" xsi:type="array">
                     <item name="true" xsi:type="string">Active</item>
                     <item name="false" xsi:type="string">Deactive</item>
            <item name="default" xsi:type="string">Active</item>

and also with the option xml attribute:

<argument name="data" xsi:type="array">
        <item name="options" xsi:type="object">\Vendor\Module\Model\Adminhtml\System\Config\Source\ActiveDeactive</item>

Your Answer

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

Browse other questions tagged or ask your own question.