Zend_Form fails with addElement "_description" -> Call to a member function getOrder() on a non-object

StackOverflow https://stackoverflow.com/questions/22863143

Domanda

I use Zend with smarty. if i try to addElement this "_description"-field to a Zend_Form and show it, even when not populated, it fails with: Fatal error: Call to a member function getOrder() on a non-object in library\Zend\Form.php on line 3324

class Form_Test_Neu extends Zend_Form
    {
        public function init()
        {
        $this->setMethod('post');

        $this->addElement('text', '_description', array(
                'label'     => 'description:',
                'size'  => 30,
                'filters'   => array('StringTrim'),
                ));
        $this->addElement('submit', 'submit', array(
                'ignore'    => true,
                'label'     => 'Submit',
                ));

        $this->addElement('hash', 'csrf', array(
                'ignore'    => true,
                ));

        }
    }

if i change "_description" to anything else, it works.

i use a model with "description" as key, and the mysql-fieldname is named like that, so i dont want to change the mapper/form to anything else here. someone can explain and maybe even give a workaround?

È stato utile?

Soluzione

I've gotten around the problem by adding the offending element to a display group. In this case, you'll probably want to add all elements to the same display group:

$this->addDisplayGroup(
    array(
        '_description',
        'submit',
        'csrf',
    ),
    'neu1'
);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top