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?
1 Answer 1
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.
Explore related questions
See similar questions with these tags.