-- Jon R <[EMAIL PROTECTED]> wrote
(on Saturday, 19 April 2008, 09:38 AM +0100):
> I like the way you can get individual elements from the form object  
> using Zend_From::getElement(). Like so:
>
> echo $this->form->getElement('myElement');

BTW, Zend_Form uses overloading, so you can actually simplify this
further:

    echo $this->form->myElement;

> I'm using this method to render certain elements (visually) elsewhere on  
> the page, giving me greater flexibility over layout. However, when you  
> render an element with Zend_From::getElement() it (rightly so) renders  
> outside of the HTML <form> </form> tags.
>
> So my question is; how do i use Zend_From::getElement() to render an  
> element inside of the HTML <form> </form> tags? I'm assuming i will have  
> to render the opening <form>  tag and closing form tag </form> using  
> Zend_From::getElement() as well? - however i don't know how to do so!

Use the form() view helper:

    echo $this->form(
        $this->form->getAttrib('name'),
        array(
            'action' => $this->form->getAction(),
            'method' => $this->form->getMethod()
        ),
        $this->form->myElement->render($this)
    );

Or, you can simply create the <form> tags by hand:

    <form action="<?= $this->form->getAction()?>"
          method="<?= $this->form->getMethod()?>">
          <?= $this->form->myElement ?>
    </form>

etc.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to