views:

461

answers:

4

Hi all,

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.

A: 

add them before other elements ;-)

zerkms
A: 

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.

berty
A: 

For me it's working as expected. The result is:

alt text

What version of Zend Framework are you using?

Luiz Damim
it work when i dont use $firstName->setDecorators($this->elementDecorators);when i use decorates it does not worki use zend 1.9
ulduz114
What is the content of `$this->elementDecorators`? I mean, what are the decorators that you're using?
Luiz Damim
A: 

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.

Mike