1

I am creating a custom module that adds MassAction in sales_order_grid:

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <listingToolbar name="listing_top">
        <massaction name="listing_massaction">
             <action name="order_complete">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="type" xsi:type="string">order_complete</item>
                        <item name="label" xsi:type="string" translate="true">Complete Order(s-ASOFT)</item>
                        <item name="url" xsi:type="url" path="completeorder/completeorder/massComplete"/>
                        <item name="confirm" xsi:type="array">
                            <item name="title" xsi:type="string" translate="true">Complete Order(s)</item>
                            <item name="message" xsi:type="string" translate="true">Are you sure you wan't to complete selected items?</item>
                        </item>
                    </item>
                </argument>
            </action>
        </massaction>
    </listingToolbar>
</listing>

I have system.xml and config.xml and have a field enable which enables/disables the module functionality:

<field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
    <label>Module Enable</label>
    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>

Now what I need is that above ui_element (MassAction) should be visible only when "enable" config is set to YES, otherwise the MassAction should disappear.

1
  • were you able to find a solution for this?
    – Radu
    May 26 '20 at 7:30
-1

You can add ifconfig attribute to action tag like this:

<action name="order_complete" ifconfig="sectionId/groupId/enable">
4
  • but it gives error : Exception #0 (Magento\Framework\Exception\LocalizedException): Element 'action', attribute 'ifconfig': The attribute 'ifconfig' is not allowed.
    – Abid Malik
    Jan 27 '18 at 12:35
  • Please try adding ifconfig to block also, not sure why it's not working but it works as well on blocks
    – Kumar M
    Jan 27 '18 at 12:43
  • I did try adding it on every line but got the same error.
    – Abid Malik
    Jan 27 '18 at 15:23
  • this answer is incorrect and misleading.
    – Radu
    May 26 '20 at 7:30

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.