5

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?

5
  • Can you confirm whether Magento is adding the validate-one-required class to the checkbox elements? Aug 6 '14 at 14:11
  • @ColinO'Dell - class not added to the element.
    – Pandurang
    Aug 6 '14 at 14:30
  • @PMB I noticed a prodblem with varien form and checkbox validation recently. Have a look at magento.stackexchange.com/q/28524/158 Aug 6 '14 at 15:55
  • @DavidManners - I used getClass. It shows validation message for every checkbox. Yes there is problem with validation.
    – Pandurang
    Aug 7 '14 at 6:31
  • I used multiple select drop down instead of checkboxes
    – Pandurang
    Aug 7 '14 at 10:22
1

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.

2
  • I tried both combinations not working
    – Pandurang
    Aug 6 '14 at 14:24
  • 1
    Try required-entry or validate-select
    – Manikandan
    Aug 6 '14 at 14:48
0

Try this if you want required field means

<validate>required-entry</validate>
<validate>validate-select</validate>

Refer this link Here

1
  • 1
    @Manikkandan I tried for both. Both not working. Seems there is problem with the multiple check box validation.
    – Pandurang
    Aug 7 '14 at 8:50

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.