Top Menu

[heading title=”How can use trim in yii model” type=”h1″ font_size=”” margin_top=”30″ margin_bottom=”30″ color=””]
I have noticed that the fields do not trim/strip whitespaces and I’m wondering how I can do this.
I have a form in Yii. Here if I enter trimp values, It gives me an error. That is working fine, But if I add some spaces in front of the field,  It does not gives me an error, nor save the data, but display the data as if it is saved. when I append spaces at the end, it gives me an custom error.
Client problem
I tried:”
[code inline=”false” scrollable=”true”]array(‘name’, ‘required’, ‘trim’)[/code]
This doesn’t work and gives me an error.
Try This :
Trim /strip whitespaces for unique validation
[code inline=”false” scrollable=”true”]
return array( array(‘name_hindi, name_english’, ‘required’),
array(‘name_hindi’, ‘length’, ‘max’=>500),
array(‘name_english’, ‘length’, ‘max’=>200),
array(‘name_english’, ‘filter’, ‘filter’=>’trim’),
array(‘name_hindi’, ‘filter’, ‘filter’=>’trim’),
array(‘name_hindi’,’unique’,’message’=>'{attribute}:{value} (Name already created!)’), array(‘name_english’,’unique’,’message’=>'{attribute}:{value} (Name already created!)’), ); [/code]
 

About The Author

Leave a Reply to GuestEncam

Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Close