can a magento adminhtml field depend on more then one field or value?

前端 未结 4 1610
名媛妹妹
名媛妹妹 2020-12-17 03:40

In http://alanstorm.com/magento_system_configuration_in_depth_tutorial @AlanStorm gives a very good tutorial for system configuration.

He also explains how to use a

4条回答
  •  没有蜡笔的小新
    2020-12-17 04:09

    I'm not sure where in Alan's article it's explained, but there is how I do it: it's just a bit of javascript.
    In your group you put a comment tag with the javascript embedded into .
    For example, here is my code that checks the value of one field in order to show (or not) another one:

    
    
        
            
                general
                
                text
                1002
                1
                1
                1
                
                    
                        
                        
                                checkExpirationPeriod = function() {
                                    if ($('points_options_config_points_expiration_period').getValue() > 0) {
                                        $('points_options_config_points_expiration_reminder').up(1).appear();
                                    } else {
                                        $('points_options_config_points_expiration_reminder').up(1).fade();
                                    }
                                }
    
                                Event.observe(window, 'load', function() {
                                    Event.observe('points_options_config_points_expiration_period', 'change', checkExpirationPeriod);
                                    checkExpirationPeriod();
                                })
                            
                        ]]>
    

    as you can see, I write a small function which check one field's value to determine if show another one or not. I then link the onchange event to the function and trigger the function to show correct fields as the page is loaded.
    For your needs, just add the condition in the js function.
    Hope That Helps

提交回复
热议问题