Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento重写现有表单并更新现有字段_Magento - Fatal编程技术网

Magento重写现有表单并更新现有字段

Magento重写现有表单并更新现有字段,magento,Magento,我想更新Magento后端中的现有表单。因为我不想接触原始扩展名,所以复制了文件并重写了类: class Bleedo_xta_Block_Adminhtml_xta_Edit_Tab_information extends Hedox_xta_Block_Adminhtml_xta_Edit_Tab_information { protected function _prepareForm() { parent::_prepareForm(); $form = $this-&g

我想更新Magento后端中的现有表单。因为我不想接触原始扩展名,所以复制了文件并重写了类:

class Bleedo_xta_Block_Adminhtml_xta_Edit_Tab_information extends Hedox_xta_Block_Adminhtml_xta_Edit_Tab_information {
protected function _prepareForm() {
    parent::_prepareForm();
    $form = $this->getForm();
这是可行的(如果您是通过Google找到这篇文章的,请不要忘记在config.xml中插入此重写)

如果我想在此表单中添加一个新字段,您可以通过

$options = $form->getElement('options_form');

    $options->addField('new_cost', 'text', array(
                'name' => 'new_cost',
            'label' => $this->__('New Cost'),
    ));
但如何更新现有字段?问题是我想将一个已经存在的字段设置为“required”。但是如果我使用addField,我会得到一个错误


非常感谢你

您可以在表单小部件块的_prepareForm方法中执行此操作。询问smth是否不是clearWorks完美!非常感谢!:)
/* @var $elm Varien_Data_Form_Element_Text */
$elm = $this->getForm()->getElement('new_cost');
$elm->setData('required',1);