zend FrameworkでFormクラスを作成しました。Zend Frameworkのフォーム要素に正規表現バリデーターを追加する
クラスApplication_Form_UserSignupは、私がZend_Validate_Regexバリデータを使用して独自の正規表現でそれを検証したいと思い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 : < >'))
));
}
}
を拡張します。
このエラーが発生するため、構文にエラーがある必要がありますが、わかりません。
エラーがある:
メッセージ:addValidatorsに渡さ無効バリ() スタックトレース:
0は、/ usr/share/PHP/libzend-フレームワークPHP/Zendの/フォーム/エレメント.php(1217):Zend_Form_Element-> addValidators(配列)
1 /usr/share/php/libzend-framework-php/Zend/Form/Element.php(363):Zend_Form_Element-> setValidators(配列)
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( 'firstname'、Array)
4/usr/share/php/libzend-framework- PHP/Zend/Form.php(1039):Zend_Form-> createElement( 'text'、 'firstname'、Array)
5 /home/damiens/workspace/manu/application/forms/UserSignup.php(18):Zend_Form - > addElement( 'text'、 'firstname'、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()Zend_Controller_Action-> dispatch( 'signupAction')
10/usr/share/php/libzend- 9 /usr/share/php/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php(295)/usr/share/php/libzend-framework-php/Zend/Application/framework/php/Zend/Controller/Front.php(954):Zend_Controller_Dispatcher_Standard->ディスパッチ(オブジェクト(Zend_Controller_Request_Http)、オブジェクト(Zend_Controller_Response_Http))
11ブートストラップ/ bootstrap.phpの(97):Zend_Controller_Front->派遣()
12 /usr/share/php/libzend-framework-php/Zend/Application.php(366):Zend_Application_Bootstrap_Bootstrap->実行()
13/home/damiens/workspace/manu/public/index.php(26):Zend_Application-> run()
14 {ma in}
ご了承ください。
、パターンがする必要があるだろう '/^[^ <>] $/i'この作業に –