zend framework2 - zf2 formFilter regex howto -
using zendframework v2, have run problem regex validator on field created form factory. other fields (using same pattern) work without problem.
any tips, or pointers appreciated.
$inputfilter->add($factory->createinput([ 'name' => 'organizationname', 'filters' => array( array('name' => 'striptags'), array('name' => 'stringtrim'), ), 'validators' => array( array( 'name' => 'notempty', 'options' => array( 'messages' => array( \zend\validator\notempty::is_empty => 'organization name field empty', ), ), ), array( 'name' => 'regex', 'options' => array( 'pattern' => '/^[a-z0-9 &-_\.,@]{3,25}$/i', 'messages' => array( \zend\validator\regex::invalid => 'invalid input, a-z, 0-9 & - _ . characters allowed', ), ), ), array ( 'name' => 'stringlength', 'options' => array( 'encoding' => 'utf-8', 'min' => '2', 'max' => '25', 'messages' => array( \zend\validator\stringlength::too_short => 'organization name field must @ least 8 characters in length', \zend\validator\stringlength::too_long => 'organization name field must no longer 25 characters in length', ), ), ), ), ]));
additional details: using zf2 generate form, create validation filter , use controller handle proper form submissions.
the problem having above inputfilter object handles "organizationname" regex filter.
it seems although regex patter use both in form definition , input filter of [a-z0-9 &-_.,@]{3,25} not handle string intl. widgets inc. though not error message $form->getmessages() etc.
color me stumpted
that's because regexp match intl. widgets inc.
: http://rubular.com/r/opbk2cdarb
Comments
Post a Comment