I have a form build with zend using a viewscript. I thought that by using a viewscript I’d get all the dd and dt eliminated and be able to use my own html tags on the form of the form script file (patientScriptForm.phtml)?
How do I use only the div tags in my form script file and not auto-generated dt and dd tags? Thanks!!
I have a very basic form with code below:
$age = new Zend_Form_Element_Text('age'); $age->setLabel('age');
$submit = new Zend_Form_Element_Submit('submit'); $submit->setValue($submit);
$this->addElement($age)->addElement($submit);
$this->setDecorators(array ( array ('ViewScript', array('viewScript' => 'patientScriptForm.phtml'))));
Below is my viewscript patientScriptForm.phtml
<form action="<?php echo $this->escape($this->element->getAction()) ?>" method="<?php echo $this->escape($this->element->getMethod()) ?>">
<div>
<?php echo $this->element->age ?>
</div>
<div>
<?php echo $this->element->submit ?>
</div>
</form>
Below is the browser output:
<form action="" method="post">
<div>
<dt id="age-label">
<label for="age" class="optional">age</label>
</dt>
<dd id="age-element">
<input type="text" name="age" id="age" value="" />
</dd>
</div>
<div>
<dt id="submit-label">
</dt>
<dd id="submit-element">
<input type="submit" name="submit" id="submit" value="submit" />
</dd>
</div>
</form>
The problem is that whilst using the
ViewScriptdecorator for the form works for the form element itself, your elements each have their own default decorator scheme.A simple solution in your view script could be