Issue
My form validate empty fields, but if the user use "space", the validation handle how one character.. How to use Trim() in Model-Table for it not happen?
Solution
Assuming that you have a title column in Posts table and you want to trim title before validating.
put following code in src\Model\Table\PostsTable.php
public function beforeMarshal(Event $event, ArrayObject $data)
{
$data['title'] = trim($data['title']);
}
and add following two lines at the top of src\Model\Table\PostsTable.php
use Cake\Event\Event;
use ArrayObject;
Thanks
Answered By - Fazal Mohammad
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.