Hello all. I am new here and this is my first question.
I am building a form that integrates Zend_Form_Element_Captcha.
In this form, I use JavaScript to add/remove the default value of the text box when onfocus and onblur, in order to avoid having to use actual labels in the design.
Here is my code:
For reference, javaHelper->dynamicDefaultArray('Password') simply returns:Code:$javaHelper = new forms_JavaHelper(); //... $password=new Zend_Form_Element_Text('password'); $password ->setLabel('Password'); $password ->addValidator('NotEmpty', true); $password ->setRequired('true') ->setValue('Password:'); $password ->setOptions($javaHelper->dynamicDefaultArray('Password:')); $password->getValidator('NotEmpty')->setMessage('You must enter a Password.'); $password ->setDecorators(array( 'ViewHelper', 'Description', array(array('data'=>'HtmlTag'), array('tag' => 'td','valign' => 'top','class'=>'required')), array(array('row'=>'HtmlTag'),array('tag'=>'tr')) )); $captcha = new Zend_Form_Element_Captcha( 'captcha', // This is the name of the input field array( 'label' => 'Verification Image', 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'font' => '../library/fonts/Impact.ttf', 'fontSize' => 28, 'imgDir' => '../public/images/captcha/', 'imgUrl' => '/images/captcha/', 'DotNoiseLevel' => 6.5, 'LineNoiseLevel' => 6.5, 'width' => 160, )));
Here is what the form currently looks like:Code:array( 'onfocus'=>'javascript:if(this.value==\'Password:\'){this.value=\'\'};', 'onblur' => 'javascript:if(this.value==\'\'){this.value=\'Password:\'};', )
What I am inquiring about is adding a "Default Value" and "Options" to the "captcha-input" field.
I have tried to rebuild the decorator stack, but I can not seem to get anything attached to the captcha-input field.
Any tips would be greatly appreciated.
Thanks,
mdeckeraz