Magento – How to validate field type checkboxes in system.xml

system.xml

I am using magento 1.9.
In my custome module, In system.xml added field type checkboxes.

<show_featuredproduct translate="label">
    <label>Show Featured Product On</label>
    <frontend_type>checkboxes</frontend_type>
    <source_model>adminhtml/system_config_source_frequency</source_model>
    <validate>validate-one-required</validate>
    <sort_order>1</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
 </show_featuredproduct>

I want to add validation for this field. I used <validate>validate-one-required</validate> but its not working.
Any Idea?

Best Answer

It's likely not working for 1 of 2 reasons:

1. The class isn't being applied to the input elements.

If this the case, try using <frontend_class>validate-one-required</frontend_class> instead, and see whether that applies the class.

2. The validate-one-required rule isn't working as expected.

You can try using validate-one-required-by-name instead, which Magento seems to use frequently with other sets of checkboxes.

Try one (or both) combinations, and hopefully that'll do the trick.

Related Topic