0

I have created a custom cron and I want to add yes/no config field under Stores -> Config -> Advanced -> System -> Cron group

I'm copying the /vendor/magento/module-cron/etc/adminhtml/system.xml file in my custom module as below and added one yes/no field but it's not working.

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="system">
            <group id="cron" translate="label comment" type="text" sortOrder="15" showInDefault="1">
                <label>Cron (Scheduled Tasks)</label>
                <comment>For correct URLs generated during cron runs please make sure that Web &gt; Secure and Unsecure Base URLs are explicitly set. All the times are in minutes.</comment>
                <group id="yes_no" translate="label" type="text" sortOrder="10" showInDefault="1">
                    <label>Cron configuration options for group:</label>
                    <field id="yes_no_field" translate="label" type="text" sortOrder="10" showInDefault="1" canRestore="1">
                        <label>Yes/NO Cron</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>
                    <field id="schedule_generate_every" translate="label" type="text" sortOrder="10" showInDefault="1" canRestore="1">
                        <label>Generate Schedules Every</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="schedule_ahead_for" translate="label" type="text" sortOrder="20" showInDefault="1" canRestore="1">
                        <label>Schedule Ahead for</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="schedule_lifetime" translate="label" type="text" sortOrder="30" showInDefault="1" canRestore="1">
                        <label>Missed if Not Run Within</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="history_cleanup_every" translate="label" type="text" sortOrder="40" showInDefault="1" canRestore="1">
                        <label>History Cleanup Every</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="history_success_lifetime" translate="label" type="text" sortOrder="50" showInDefault="1" canRestore="1">
                        <label>Success History Lifetime</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="history_failure_lifetime" translate="label" type="text" sortOrder="60" showInDefault="1" canRestore="1">
                        <label>Failure History Lifetime</label>
                        <validate>validate-zero-or-greater validate-digits</validate>
                    </field>
                    <field id="use_separate_process" translate="label" type="select" sortOrder="70" showInDefault="1" canRestore="1">
                        <label>Use Separate Process</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>
                </group>
            </group>
        </section>
    </system>
</config>

Let me know if anyone has any ideas

1 Answer 1

0

What are you trying to achieve?

To hide a config based on the value of another field, you would a depends node inside the field node, like this:

<field>
    <depends>
        <field id="your_target">1</field>
    </depends>
</field>
1
  • please check updated question
    – Mohit Rane
    Feb 1, 2022 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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