Student
Student

Reputation: 1863

Zend captcha html

I am creating captcha like this using Zend_Form:

class Form_Signup extends Zend_Form {

    public function __construct( array $options = null ) {

        // set method
        $this->setMethod('post');

        // other elements here        

        // captcha 
        $captcha = new Zend_Form_Element_Captcha('captcha', array(
                'id'=>'captcha',
                'title'=>'Security Check.',
                'captcha' => array(
                'captcha' => 'Image',
                'required' => true,
                'font'=> 'fonts/ARIALN.TTF',
                'wordlen'=>'4',
                'width'=>'200',
                'height'=>'50',
                'ImgAlign'=>'left',
                'DotNoiseLevel'=>'30',
                'LineNoiseLevel'=>'7', 
                'Expiration'=>'1000',
                'fontsize'=>'30',
                'gcFreq'=>'10',
                'imgdir'=> 'images/captcha/',
                'ImgAlt'=>'Captcha',
                'imgurl'=>'/images/captcha/'
                )));
        $captcha->removeDecorator('HtmlTag')
        ->removeDecorator('Label')
        ->addDecorator('Label');        

        // add captcha
        $this->addElement( $captcha );          
        $this->setDecorators( array( array( 'ViewScript', array( 'viewScript' => 'signup/signup-form.phtml' ) ) ) );    
    } 

}

It is generating HTML like this:

<img width="200" height="50" alt="Captcha" src="/images/captcha/cabf4d4d759ae8e4b7404b95e032e231.png">
<input type="hidden" name="captcha[id]" value="cabf4d4d759ae8e4b7404b95e032e231" title="Security Check." id="captcha">
<input type="text" name="captcha[input]" id="captcha" value="" title="Security Check.">

But I want textbox of captcha below the image like this:

<img width="200" height="50" alt="Captcha" src="/images/captcha/cabf4d4d759ae8e4b7404b95e032e231.png">
<br />
<input type="hidden" name="captcha[id]" value="cabf4d4d759ae8e4b7404b95e032e231" title="Security Check." id="captcha">
<input type="text" name="captcha[input]" id="captcha" value="" title="Security Check.">

Any idea ?

Thanks

Upvotes: 2

Views: 1494

Answers (1)

Rajan Rawal
Rajan Rawal

Reputation: 6313

Zend Captcha element decorators are little complected. The batter solution to this is to create our own decorators. And once you are done with it. you can change the order as you want

You can find complete answer here

If you are not in hurry, and if you have enough time then Go through this article by Methew explaining how to play with decorators.

Near about same question I asked here, where I dont wanted to create a Separate decorator class, but did not get any proper answer. And then I did some css trick and forced <input type='text'> to go down. So only solution is to generate Custom captcha decorator class.

If you don't get anything there then let me know. Thank you

Upvotes: 1

Related Questions