Carol Casta
Carol Casta

Reputation: 85

html in ZF2 Form

I wanted to know how I can remove all the HTML that form zend framework 2 automatically add?

I want the result for each input is this:

<label for="email" class="required"> Email </ label>
<input type="text" name="email" id="email" value="" class="span5">

and not this:

<label>
<span> Email </ span>
<input type="text" name="email" class="span5" value="">
</ label>

how can I do?

Upvotes: 0

Views: 239

Answers (1)

Haver
Haver

Reputation: 443

Check the form rendering http://framework.zend.com/manual/2.0/en/modules/zend.form.quick-start.html#rendering.

you can do smoothing like this:

// set the needed atributes
$email = new Element\Email('email');
$email->setLabel('Contact Email')
 ->setAttribute('title', 'Please enter your email address')
->setAttribute('id', 'email')
->setAttribute('value', 'Email')
->setAttribute("onfocus", 'if(this.value==\'Email\')this.value=\'\'')
->setAttribute('onblur', 'if(this.value==\'\')this.value=\'Email\'');

// this for rendering in your phtml file
$email = $form->get('emali');
echo $formLabel->openTag() . $name->getOption('label');
echo $formLabel->closeTag();
echo $this->formInput($name);
echo $this->formElementErrors($name);

Upvotes: 1

Related Questions