Fügen Sie einen regex-validator auf ein Formular-element in das Zend Framework

Ich ein Formular erstellt Klasse im zend Framework.

Klasse Application_Form_UserSignup extends Zend_Form
{

public function init()
{
    //Set the method for the display form to POST
    $this->setMethod('post');

    //Add an Firstname element
    $this->addElement('text', 'firstname', array(
                              'label'      => 'Your first name:',
                              'required'   => true,
                  'validators' => array('regex', false, array(
                'pattern'   => '/[^<>]/i',
                'messages'  =>  'Your first name cannot contain those characters : < >'))
    ));
    }

}

Ich würde gerne überprüfen, es mit meinen eigenen regex mit dem Zend_Validate_Regex validator.

Muss es ein Fehler in der syntax, weil ich bekomme diese Fehlermeldung, aber ich kann nicht es herausfinden.

Der Fehler ist :

Meldung: Ungültige validator übergeben addValidators()
Stack trace:

0 /usr/share/php/libzend-framework-php/Zend/Form/Element.php(1217): Zend_Form_Element->addValidators(Array)

1 /usr/share/php/libzend-framework-php/Zend/Form/Element.php(363): Zend_Form_Element->setValidators(Array)

2 /usr/share/php/libzend-framework-php/Zend/Form/Element.php(253): Zend_Form_Element->setOptions(Array)

3 /usr/share/php/libzend-framework-php/Zend/Form.php(1108): Zend_Form_Element->__construct('Vorname', Array)

4 /usr/share/php/libzend-framework-php/Zend/Form.php(1039): Zend_Form->createElement('text', 'Vorname', Array)

5 /home/damiens/workspace/manu/application/forms/UserSignup.php(18): Zend_Form->addElement('text', 'Vorname', Array)

6 /usr/share/php/libzend-framework-php/Zend/Form.php(240): Application_Form_UserSignup->init()

7 /home/damiens/workspace/manu/application/controllers/UsersController.php(35): Zend_Form->__construct()

8 /usr/share/php/libzend-framework-php/Zend/Controller/Action.php(513): UsersController->signupAction()

9 /usr/share/php/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php(295): der Zend_Controller_Action erweitert->dispatch('signupAction')

10 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))

11 /usr/share/php/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()

12 /usr/share/php/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()

13 /home/damiens/workspace/manu/public/index.php(26): Zend_Application->run()

14 {main}

Jede mögliche Hilfe würde geschätzt !

InformationsquelleAutor damiens | 2011-08-15
Schreibe einen Kommentar