Take the 2-minute tour ×

I would like to create a form with a label that would contain two different styles, for example:

"Email (enter your email):"

How can I do that? Right now I am using the label attribute of the addElement() method:

$form->addElement('text', 'email', array(
    'label'    => 'Email',
    'required' => true,

With this method I only get a label attribute to the form tag, and can't use different styling inside it.

Thank you!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Do you already use the Label decorator ? If yes, just use this code :

    'label'    => '<strong>Email</strong> (enter your email)',
    'required' => true,
/* Here some code to add the Label decorator */
$form->getElement('email')->getDecorator('Label')->setOption('escape', false);

And this is done. I just added the <strong> tag to the label, and asked the Label decorator not to escape this tag. It's also working for any html content. This is how I could put images in some checkboxes labels :) (country flags to choose the language)

share|improve this answer
add comment

Your Answer


