Last active
August 29, 2015 13:56
-
-
Save matstani/9303960 to your computer and use it in GitHub Desktop.
ZF2 InputFilterの例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
$inputFilter->add(array( | |
'name' => 'title', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( | |
array( | |
'name' =>'NotEmpty', | |
'break_chain_on_failure' => true, | |
'options' => array( | |
'messages' => array( | |
\Zend\Validator\NotEmpty::IS_EMPTY => '項目は必須です' | |
) | |
) | |
), | |
array( | |
'name' => 'StringLength', | |
'options' => array( | |
'encoding' => 'UTF-8', | |
'min' => 1, | |
'max' => 100, | |
'messages' => array( | |
\Zend\Validator\StringLength::TOO_SHORT => '1文字以上入力して下さい', | |
\Zend\Validator\StringLength::TOO_LONG => '100文字以内で入力して下さい', | |
), | |
), | |
), | |
), | |
)); | |
//... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment