2010年10月22日星期五

Re: [fw-mvc] Forms and HTML

Thomas,

You would either have to create a decorator or you can echo out all the
form elements in the view with the label turned off.

An example with the label decorator turned off:
$this->email
->setRequired(true)
->addFilter('StripTags')
->addValidator('EmailAddress')
->*removeDecorator('Label');*

*View:*
<table>
<tr>
<td>YOUR LABEL HERE</td>
<td><?php echo $this->form->email?></td>
</tr>
</table>


You could also just add a class to those elements and do your styling in
CSS.

$this->email
->setOptions(array('class' =>
'CLASS_NAME_HERE'))
->setRequired(true)
->addFilter('StripTags')
->addValidator('EmailAddress')
->removeDecorator('Label');

Tully Rankin
PHP Developer
www.tullyrankin.com


On 10/22/2010 12:53 PM, Thomas List wrote:
> I've been trying without any luck to add HTML to a Zend_Form. I started out with just trying to add a font to a label for one of the fields in my form:
>
> $this->addElement('select','types', array(
> 'label' => 'What type of home do you live in:',
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));
>
>
> but when I add the html, Zend just renders it as text. I've read something about adding an esacape=>false to $decorators element or something, but I really am not sure how to do so. I would really appreciate some guidance on this, as I can't seem to find a straightforward example.
>
> Thanks,
> Thomas List
>
>

没有评论: