开发者

Problem with addDisplayGroup in the Zend Form

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',), '开发者_如何学PythonsubmitButtons', 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.


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.


add them before other elements ;-)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜