views:

204

answers:

1

I've been working with Zend Framework for a couple weeks so this might be a complete noobie question but I'm wondering if there's a way to customize the layout of forms in an explicit way using Zend_Form. I've looked all over the place but every example of Zen-Form I've found use the echo example.

For example, when I work with Smarty and HTML_QuickForm I have the option of placing each form element onto the page where ever I want.

{if $Form.errors}<span class="errorMessage">Error!</span>{/if}
{if $Form.Email.error}Fill out field{if}
{$Form.Email.html}
{$Form.Submit.html}

But with Zend Framework it looks like I have to decorate the form elements in the actual php code and echo the completed form:

echo $this->form;

If it's not possible are there any php frameworks that do allow this level of control?

+4  A: 

Hi, you can render each element seperatly.

Just use

<?php echo $this->form->age ?>
<?php echo $this->form->lastname ?>

in your view-script, to render only some "elements". To render Form-Controlls use :

<form action="<?php echo $this->escape($this->form->getAction() ?>"
      method="<?php echo $this->escape($this->form->getMethod() ?>">

You can find more examples here :

Decorate Zend Forms on DevZone

ArneRie
Thanks heaps! This worked.
helloworlder