For anyone in the future who happends to be looking for something similar.
Here is what I ended up doing..
$elementCaptcha->setDecorators(array(
array('decorator' => array('td' => 'HtmlTag'), 'options' =>
array('tag' => 'td')),
array('Label', array('tag' => 'td'))
));
Wraps <td>'s arround the label and the image/textbox of the captcha item.
Then I extended the Zend_Form_Element_Captcha to replace the render function
so that the return is wrapped in a <tr>.
Like so,
class myCaptcha extends Zend_Form_Element_Captcha {
public function render(Zend_View_Interface $view = null)
{
$captcha = $this->getCaptcha();
$captcha->setName($this->getFullyQualifiedName());
$decorators = $this->getDecorators();
$decorator = $captcha->getDecorator();
if (!empty($decorator)) {
array_unshift($decorators, $decorator);
}
$decorator = array('Captcha', array('captcha' => $captcha));
array_unshift($decorators, $decorator);
$this->setDecorators($decorators);
$this->setValue($this->getCaptcha()->generate());
return '<tr>'.parent::render($view).'</tr>';
}
}
It's the same render function as the existing one in
Zend_Form_Element_Captcha but with the <tr>'s added on the return.
Terre
-----Original Message-----
From: Terre Porter [mailto:[EMAIL PROTECTED]
Sent: Monday, November 10, 2008 7:29 PM
To: [email protected]
Subject: [fw-general] help setDecorators for Zend_Form_Element_Captcha
I'm trying to create a captcha form element in a table row.
I have this for a text element.
// set <tr><td> wrapper around element
$email->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array(array('data'=>'HtmlTag'), array('tag' => 'td')),
array('Label', array('tag' => 'td')),
array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
));
It creates this :
<tr>
<td><label for="email" class="required">E-Mail</label></td>
<td><input type="text" name="email" id="email" value=""
maxlength="125"></td>
</tr>
However, the same setDecorators statement on Zend_Form_Element_Captcha
doesn't work.
Anyone know the correct syntax to make something like this :
<tr>
<td><label for="captcha" class="required">Enter Code:</label></td> <td><img
src="/images/captcha/1d97a252be45739b5f6c83583b02f4d8.png"/><br/><input
type="hidden" name="captcha[id]" value="1d97a252be45739b5f6c83583b02f4d8"
helper="formText" id="captcha-id"><input type="text" name="captcha[input]"
id="captcha-input" value="" helper="formText"></td> </tr>
Thanks
Terre