我的 costum magento 管理表单中有一个这样的选择字段
$fieldset->addField(
'category_id',
'select',
array(
'id' => 'lazadaCategory',
'label' => Mage::helper('test_sellercenter')->__('Category '),
'name' => 'status',
'values' => Mage::helper('test_sellercenter/dropdown')->getLazadaCategories(),
'class' => 'required-entry',
)
);
and when the select value change i need to add another fields below this select field (not like toogle show/hide just add), for example like this field
$fieldset->addField(
'listing_name',
'text',
array(
'label' => Mage::helper('test_sellercenter')->__('Listing Name'),
'name' => 'listing_name',
'required' => true,
'class' => 'required-entry',
)
);
有没有办法在 magento 中做到这一点?
最佳答案
如果您不想使用显示/隐藏,那么您可以使用 javascript 从前端添加字段,如果您需要来自 magento(后端)的值,则在将第一个字段更改为自定义字段时进行 ajax 调用用于获取所需数据然后添加第二个字段的 Controller 操作,您可以在自定义表单模板中执行此操作
关于php - 字段选择值更改时如何在 Magento 自定义管理表单中添加字段集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41278819/