2014-02-13 75 views
0

我想在系統配置中顯示用於選擇值的動態選擇框。我添加了圖像中顯示的文本框,它很容易添加文本框,但是如何添加與文本框相同的選擇框。如何在magento配置文件中添加動態選擇框

我加入以下代碼來顯示動態文本框:

<fields> 
    <product_option translate="label"> 
          <label>Tour Options</label> 
          <backend_model>adminhtml/system_config_backend_serialized_array 
          </backend_model> 
          <frontend_model>customoptioncreater/adminhtml_system_config_form_field_additem 
          </frontend_model> 
          <sort_order>31</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>1</show_in_store> 
          <comment>Add Tour Options Item</comment> 
         </product_option> 
         </fields> 

而創建的模型文件來渲染HTML:

enter image description here

任何幫助將非常感激。

回答

0

你可以利用你的frontendmodel的

<frontend_model>customoptioncreater/adminhtml_system_config_form_field_additem</frontend_model> 

在那裏,你可以添加JS代碼,如:

echo '<script> // YOUR CODE </script>'; 

那你可以在後臺「注入」 JS的方式,使其更動態