Create a gist now

Instantly share code, notes, and snippets.

ZF2 InputFilterの例
<?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