嗨,我使用ZF1並有一個問題。這裏是我的形式使用HtmlEntities過濾器Zend框架maxlength驗證
$htmlEntities = new Zend_Filter_HtmlEntities(array(
'doublequote' => false,
'quotestyle' => ENT_NOQUOTES /*| ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5*/
));
$elements[] = $this->createElement('text','name',array(
'belongsTo' => 'event_waiver',
'class' => 'form-text tx name',
'label' => $this->_translate->_('Title'),
'required' => true,
'value' => $this->object->name,
'description'=> $this->_translate->_('Select a unique title for your waiver. This is how your waiver will be saved and identified within your organization.'),
'maxlength' => 50,
'filters' => array('StripTags','StringTrim',$htmlEntities,'Null'),
'validators' => array(
array('StringLength',null,array('max'=>50))
)
));
我的問題是,如果我嘗試鍵入希臘字符,例如30個字符長,我會得到驗證錯誤「最大字母數爲50」的辯論,因爲「最大長度」 => 50,部分代碼。發生這種情況是因爲應用了htmlenteties過濾器;有沒有人有想法如何覆蓋此行爲