0

Similar to native Magento URL Key Create Permanent Redirect for old URL: enter image description here

I have a custom module and wants to achieve same result: I have created a group exactly how category_form.xml in my_form.xml

...
   <settings>
            <collapsible>true</collapsible>
            <label translate="true">SEO</label>
        </settings>
        <container name="url_key_group" component="Magento_Ui/js/form/components/group" sortOrder="10">
            <argument name="data" xsi:type="array">
                <item name="type" xsi:type="string">group</item>
                <item name="config" xsi:type="array">
                    <item name="required" xsi:type="boolean">false</item>
                </item>
            </argument>
            <field name="url_key">
                <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">URL Key</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">blog</item>
                <item name="dataScope" xsi:type="string">url_key</item>
                </item>
                </argument>
            </field>
            <field name="url_key_create_redirect" component="Magento_Catalog/js/components/url-key-handle-changes" sortOrder="11" formElement="checkbox">
                <settings>
                    <dataType>boolean</dataType>
                </settings>
                <formElements>
                    <checkbox>
                        <settings>
                            <description translate="true">Create Permanent Redirect for old URL</description>
                            <valueMap>
                                <map name="false" xsi:type="number">0</map>
                                <map name="true" xsi:type="number">1</map>
                            </valueMap>
                        </settings>
                    </checkbox>
                </formElements>
            </field>
        </container>
  ...

in js: Magento_Catalog/js/components/url-key-handle-changes

I have add a console.log:

handleChanges: function (newValue) {
            console.log(newValue)
            this.disabled(newValue === this.valueMap['true'] || this.useDefault.checked);
        },

I can see is consoling the new value so everything seems to be in place but is doesn't seem to be disabling and enabling the checkbox does anyone know I am missing something?

| improve this question | | | | |

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.