php - 字段选择值更改时如何在 Magento 自定义管理表单中添加字段集

标签 php magento

我的 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/

相关文章:

magento - magento 如何知道哪个商店使用?

关于缓存新产品的 Magento 添加到购物车问题

ajax - Magento:在 AJAX 响应中获取所有更新的购物车项目数据

linux - AWS 为自动生成的文件设置文件权限

javascript - 创建一行代码和一个脚本来从另一个站点(例如 Twitter、分析等)回调表中的数据库信息

跨子域的 PHP session 2

php - paypal IPN 不发送任何通知

php - MYSQLi 日期格式 - 选择查询

Magento 2空白页面但不为空

php - 多重引用的数据类型是什么?