【发布时间】:2016-12-18 14:04:31
【问题描述】:
我想在magento2中实现动态表单字段
用户可以根据需要添加尽可能多的图像,就像添加更多选项一样,
我通过在编辑时添加 10 个新图像来实现这一点,但用户无法在途中添加更多图像
在表格之后我写了这个
$newfieldset = $form->addFieldset('new_fieldset', ['legend' => __('New Images #')]);
foreach (range(0, 10) as $newid) {
$newfieldset->addField(
"newimages_$newid",
'image',
['name' => 'galleryimages[]', 'label' => __('New Image #'.$newid), 'title' => __('New Image #'.$newid), 'required' => false , 'disabled' => $isElementDisabled]
);
}
$this->setForm($form);
return parent::_prepareForm();
让我知道这是否可以像点击按钮一样动态地完成添加图片新字段添加到表单中
【问题讨论】:
标签: javascript admin magento2