Question

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!

Was it helpful?

Solution

/* @var $elm Varien_Data_Form_Element_Text */
$elm = $this->getForm()->getElement('new_cost');
$elm->setData('required',1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top