0

I'm using ZendFramework 1.11 and Zfdatagrid 0.8.

I've created a grid and a CRUD-form using my own db-model as source. Then I added some extra elements to the CRUD-form like this:

$element = new Zend_Form_Element('element', array('label'=>'new element:')); $grid->getForm(1)->addElement($element);

The new element is added to the form properly, but whereas all other form elements are within a table, the added element is placed as a list element above the actual form. Instead of this, i would like to have the added element as a part of the table to achieve a proper look of the form. Has anybody faced this issue before or an idea of how to do it? Any help is appreciated!

Thanks in advance!

1 Answers1

1
 $elementDecorators = array(
            'ViewHelper',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
            array('Label', array('tag' => 'td', 'class' => 'form_label')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
        );

$this->_grid->getForm(1)->addElement('select', 'group', array(
            'required' => true,
            'value' => 'rtrt',
            'label' => 'Group',
            'multiOptions' => $list_contactgroup,
            'order' => 5, 'decorators' => $elementDecorators
        ));
mroot
  • 26
  • 1
  • You should explain what you are doing and why this code will help, rather than just posting undocumented code. – Sam Oct 15 '12 at 19:28
  • Thank you for your submission, you where absolutely right! I have already tried to set the decorators in the past but I failed at some point... now i defined the decorators your way and set the decorators for the desired element like this: $element->setDecorators($elementDecorators); I dont know if this is a good solution but it is very simple and works for me at least ;) Thx again for your help! – user1595158 Nov 20 '12 at 16:02