2011-12-20 9 views
5

मैं Zend कैप्चा उपयोग करने की आवश्यकता है और follwoing कोड लिखा है:ज़ेंड फॉर्म में कैप्चा कैसे जोड़ें?

<?php 

    require_once ('Zend/Form.php'); 

    class Form_Signup extends Zend_Form { 

     public function __construct($options = null) { 

      parent::__construct($options); 

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

      // Elements array 
      $elements = array(); 

      $element = new Zend_Form_Element_Captcha('captcha', array('label' => "", 
                     'captcha' => array('captcha' => 'Image', 
                         'name' => 'myCaptcha', 
                         'wordLen' => 5, 
                         'timeout' => 300, 
                         'font' => 'font/monofont.ttf', 
                         'imgDir' => 'captcha/', 
                         'imgUrl' => '/captcha/') 
                    ) 
                ); 
      $elements[] = $element; 

      // Submit Button 
      $element = $this->CreateElement('submit', 'Signup'); 
      $element->setLabel('Signup'); 
      $elements[] = $element; 

      // -------------------------- 
      // Add elements to the form 
      // -------------------------- 

      // update tabindex 
      foreach ($elements as $index => $element) { 
       $element->setAttrib('tabindex', ($index + 1)); 
      } 

      $this->addElements($elements); 
      $this->setElementDecorators(array('ViewHelper')); 

      // Set form decorator (what script will render the form) 
      $this->setDecorators(array(array('ViewScript' , array('viewScript' => 'signup/form.phtml')))); 

     } 

    } 

?> 

समस्या मैं का सामना है कि जब मैं की तरह मेरी "form.phtml" फ़ाइल में प्रदर्शित:

<?= $this->element->captcha ?> 

यह प्रदर्शित करता है निम्नलिखित:

enter image description here

यानी यह 2 बक्सें प्रदर्शित कर रहा है।

कृपया इस स्थिति का विरोध करने में मेरी मदद करें। :)

+0

यह मार्कअप पोस्ट करता है। – Dunhamzzz

+1

क्या आप एक पूर्ण Zend_Form का उपयोग कर रहे हैं, या सिर्फ कैप्चा को बाहर निकाल रहे हैं? –

+0

मैं पूर्ण Zend_Form का उपयोग कर रहा हूँ। – Ahsan

उत्तर

5

आपको दूसरा टेक्स्टफील्ड मिल रहा है क्योंकि आप कैप्चा तत्व के लिए व्यूहेल्पर सजावट का उपयोग कर रहे हैं। कैप्चा तत्व के लिए व्यूहेल्पर सजावट सेट न करें और इसे काम करना चाहिए।

0

हाय मैं अतिरिक्त क्षेत्र को दूर करने के लिए इस कोड को उपयोग कर रहा हूँ

$captcha = new Zend_Form_Element_Captcha('captcha',array('label' => 'Write the chars to the field', 
                  'captcha' => array(
                   'captcha' => 'Image', 
                   'wordLen' => 3, 
                   'timeout' => 300, 
                   'font' => APPLICATION_PATH.'/../public/font/two.ttf', 
                   'imgDir' => APPLICATION_PATH.'/../public/captcha/', 
                   'imgUrl' => 'http://localhost/projx/public/captcha/' 

                  ), 
              'decorators' => $this->elementDecorators, 
              )); 
              $captcha->removeDecorator('ViewHelper'); 

यह मेरा डेकोरेटर है

'decorators' => $this->elementDecorators, 

यह डिफ़ॉल्ट डेकोरेटर

मैं सिर्फ हटाने followig कोड

का उपयोग कर ViewHelpre है
$captcha->removeDecorator('ViewHelper'); 

मुझे आशा है कि यह आपके लिए काम करेगा ... :)

संबंधित मुद्दे