문제

I want to update an existing form in Magento backend. Because I don't want to touch the original extension I copied the file and rewrote the class:

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();

This works (if you found this article via Google, don't forget to insert this rewrite in your config.xml)

If I want to add a new field to this form you can easily do this by

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

    $options->addField('new_cost', 'text', array(
                'name' => 'new_cost',
            'label' => $this->__('New Cost'),
    ));

But how can I update an existing field? The problem is that I want to set an already existing field to "required". But if I'm using addField I get an error.

Thank you so much!

도움이 되었습니까?

해결책

/* @var $elm Varien_Data_Form_Element_Text */
$elm = $this->getForm()->getElement('new_cost');
$elm->setData('required',1);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top