I'm also attempting a custom decorator for captcha elements and found this
thread. When finally rendered, I would like to have this:
<div id="custom_id" class="custom_class">
<label id="custom_id_label" for="custom_id_text"
class="custom_class_label"><!-- label text --></label>
<p id="custom_id_description" class="custom_class_description"><!--
description text --></p>
<ul id="custom_id_errors" class="custom_class_errors"><!-- any error
messages --></ul>
<pre id="custom_id_captcha" class="custom_class_captcha"><!-- captcha
challenge --></pre>
<input type="hidden" name="captcha[id]" value="{captcha key}"
id="custom_id_key" />
<input type="text" name="captcha[text]" value="" id="custom_id_text"
class="custom_class_text" />
</div>
I've been able to accomplish this with other form elements, but I'm having
difficulty with the captcha rendering (probably due to the Captcha_Word
class?). I either get two captchas, one rendered before the div, or the
additional hidden & text inputs are rendered after the div. Could I have
some help in understanding how to store the captcha elements in a variable
as text before the actual rendering of them?
For instance, when I use:
$captcha = $element->getCaptcha()->render($view, $element);
all of the captcha elements are rendered before the div and then just the
<pre>challenge</pre> is rendered inside the div.
Also, some direction about defining the custom id & class attributes for the
elements as described above would be much appreciated.
TIA!
Matthew Weier O'Phinney-3 wrote:
>
> -- Matthew Lurz <[email protected]> wrote
> (on Sunday, 31 August 2008, 04:42 AM -0700):
>>
>> I'm having some difficulty understanding how to implement a custom
>> decorator
>> for a Captcha element. The manual states:
>>
>> "The decorator used is determined by querying the captcha adapter. By
>> default, the Captcha decorator is used, but an adapter may specify a
>> different one via its getDecorator() method."
>>
>> Since all forms and elements in the application I'm working with require
>> custom markup I call loadDefaultDecorators in the custom form and element
>> classes. Unfortunately this doesn't seem to work with the Captcha
>> element. I
>> can understand why this wouldn't work to some extent but don't understand
>> how to correctly implement a custom decorator. In a nutshell, I simply
>> need
>> to remove the DtDd wrapper with and HtmlTag.
>
> The default decorators for Captcha elements are:
>
> * Errors
> * HtmlTag (dd)
> * Label (with dt tag)
>
> When render() occurs, it shifts on the captcha decorator to the top of
> the stack. So, simply call setDecorators as usual, but without a
> ViewHelper decorator, and you'll be all set.
>
> --
> Matthew Weier O'Phinney
> Software Architect | [email protected]
> Zend Framework | http://framework.zend.com/
>
>
--
View this message in context:
http://www.nabble.com/Zend_Form_Element_Captcha-%2B-Custom-Decorator-tp19241501p24466277.html
Sent from the Zend Framework mailing list archive at Nabble.com.