1

I keep getting this error when I view my form in Magento admin:

Call to undefined function setUseContainer() in app\code\local\MasteringMagento\Example\Block\Adminhtml\Event\Edit\Form.php

Please tell me, what am I doing wrong?

class MasteringMagento_Example_Block_Adminhtml_Event_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
    $form = new Varien_Data_Form(
        array('id' => 'edit_form',
              'action' => $this->getData('action'),
              'method' => 'post'
        )
    );

    $fieldset = $form->addFieldset(
        'base_fieldset',array('legend'=> Mage::helper('example')->__('General Information'),'class'=> 'fieldset-wide'));

    $fieldset->addField('name','text',array(
        'name'    => 'name',
        'label'   => Mage::helper('example')->__('Event Name'),
        'title'   => Mage::helper('example')->__('Event Name'),
        'required' => true
    ));

    $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);

    $fieldset->addField('start','date',array(
        'name'     => 'start',
        'format'   => $dateFormatIso,
        'image'    => $this->getSkinUrl('images/grid-cal.gif'),
        'label'   => Mage::helper('example')->__('Start Date'),
        'title'   => Mage::helper('example')->__('Start Date'),
        'required' => true
    ));

    $fieldset->addField('end','date',array(
        'name'     => 'end',
        'format'   => $dateFormatIso,
        'image'    => $this->getSkinUrl('images/grid-cal.gif'),
        'label'   => Mage::helper('example')->__('Start Date'),
        'title'   => Mage::helper('example')->__('Start Date'),
        'required' => true
    ));

    $form = setUseContainer(true);
    $this->setForm($form);


    return parent::_prepareForm();

}
}
2

Replace:

$form = setUseContainer(true);

to the:

$form->setUseContainer(true);

because the setUseContainer is not a function, it is a magic method of the Varien_Data_Form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.