1

I'm learning the Magento form generation feature and I have an question related to system.xml file. Here's the code example:

 <days translate="label">
 <label>Days</label>
 <frontend_type>multiselect</frontend_type>
 <source_model>adminhtml/system_config_source_locale_weekdays</source_model>
 <sort_order>10</sort_order>
 <show_in_default>1</show_in_default>
 <show_in_website>1</show_in_website>
 <show_in_store>1</show_in_store>
 <comment>Days</comment>
 </days>
 <sunday translate="label">
 <label>Sunday</label>
 <frontend_type>multiselect</frontend_type>
 <source_model>xxx_xxx_Model_System_Config_Source_Hours</source_model>
 <sort_order>100</sort_order>
 <show_in_default>1</show_in_default>
 <show_in_website>1</show_in_website>
 <show_in_store>1</show_in_store>
 <comment>Hours in Sunday</comment>
 <depends>
 <days>0</days>
 </depends>
 </sunday>
 <monday translate="label">
 <label>Monday</label>
 <frontend_type>multiselect</frontend_type>
 <source_model>xxx_xxx_Model_System_Config_Source_Hours</source_model>
 <sort_order>110</sort_order>
 <show_in_default>1</show_in_default>
 <show_in_website>1</show_in_website>
 <show_in_store>1</show_in_store>
 <comment>Hours in Monday</comment>
 <depends>
 <days>1</days>
 </depends>
 </monday>

The source model returns list of hours - from 0 to 23.

Why when I select Sunday and Monday only Sunday dependency appears, but when I select only Monday, the Monday dependency appears as it should, but how to get working multiple dependences with multiselect field?

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Nov 6, 2015 at 15:41

1 Answer 1

2

Why when I select Sunday and Monday only Sunday dependency appears, but when I select only Monday, the Monday dependency appears as it should

In PrototypeJS/JavaScript, $('multiselect').value will always return, in order of appearance, the first selected option only. This first selected option is then compared with the value given as dependecy:

  • Sunday + Monday = Sunday
  • Monday = Monday
  • Monday + Tuesday + Wednesday = Monday

how to get working multiple dependences with multiselect field?

The only solution I can think of is replacing the original JavaScript function that is used to handle dependencies. Currently, it cannot determine multiple selected values.

answered Nov 6, 2015 at 16:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.