Reputation: 1180
I have a form same the following code:
public function init(){
$id=$this->createElement('hidden','cf_id');
$id->setDecorators($this->elementDecorators);
$id->setOrder(1);
$this->addElement($id);
$firstName=$this->createElement('text','firstName');
$firstName->setDecorators($this->elementDecorators);
$firstName->setLabel('name :');
$firstName->setOrder(2);
$firstName->setAttrib('class','textbox');
$firstName->setAttrib('disabled',true);
$this->addElement($firstName);
$lastname=$this->createElement('text','family');
$lastname->setLabel(' family:');
$lastname->setDecorators($this->elementDecorators);
$lastname->setOrder(3);
$lastname->setAttrib('class','textbox');
$lastname->setAttrib('disabled',true);
$this->addElement($lastname);
$this->addElement('button', 'cancel', array(
'label' => 'Cancel Button',
'class'=>'button',
'decorators' => array(
'ViewHelper',
),
));
$this->addElement('button', 'submit', array(
'label' => 'Submit Button',
'class'=>'button',
'decorators' => array(
'ViewHelper',
),
));
$this->addDisplayGroup(array('submit', 'cancel',), 'submitButtons', array(
'order'=>4,
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'div', 'class' => 'element')),
),
));
}
In this form there are some elements and two buttons. In display page, the buttons are shown above form before other elements.
How can I put these buttons at the bottom of all elemnts?
Thanks.
Upvotes: 2
Views: 3254
Reputation: 2778
Zend renders the elements in the order in which they are added via the addElements() method. So, I would add them like this:
$this->addElements(array(all elements you want to appear first in top-down order));
$this->addElements(array(button elements));
Then use CSS in the view to manipulate their locations.
Hope that helps.
Upvotes: 2
Reputation: 319
Add your other fields to another display group, defined before the display group you already have. You will probably need to adjust the decorators some-what.
Upvotes: 0