I want to perform a htmlspecialchars with no quotes in my entity save.
Code:
$post['body'] = htmlentities($this->request->getData('body'), ENT_NOQUOTES);
Validator doesn't work on save.
How to make it work?
Thanks
I want to perform a htmlspecialchars with no quotes in my entity save.
Code:
$post['body'] = htmlentities($this->request->getData('body'), ENT_NOQUOTES);
Validator doesn't work on save.
How to make it work?
Thanks
The h()
method is just a wrapper for htmlspecialchars()
more information on that can be found in the Cake API https://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#h
h(string $text, boolean $double = true, string $charset = null)
The long and short of it is that the first parameter for those functions is a string and you are passing in an array of data. If you wanted to strip those out you could override the patchEntity()
with your own or individual run the special chars function on each elements
Edit: Added more clear example to keep validation
You can use the withData to set the response data and still use patch entities. for instance.
$data = $this->request->withData('body', htmlentities($this->request->getData('body'), ENT_NOQUOTES))
And then patch/validate the entity using the new request object.
patchEntity($post, $data)