Automatic trim filtering?

Hi,

Unless I'm mistaken, POST data are not trimmed by default. We do have to precise "trim" for each value. I am surprised by this behavior. How can I change it so that the framework trims POST data by default?

Thank you all,

EDIT : for now I am using my own Controller class that allows me to make some things easier, like success/error json responses... But if there is a configuration for automating trimming, I would love to learn that



18.5k

Maybe you could do a manual trim with a for each in the beforeExecute event. But that won't work with AJAX posts (as far as I know).

Mmmh, everything in my app is ajax (it is a stateless API). Although this is strange that ajax POST data would not be treated like "usual" POST data.

I'll stick with my base Controller class for now. I also created a base PDO class (extending the Phalcon Mysql class) that allows me to treat fetched data as ASSOC by default.

Thanks anyway Rompe!



18.5k

What do you mean with "usual"? Tell me, I'm also doing my app only with AJAX xD

It's you who are telling me that your method wouldn't work with Ajax POST. And I guessed you specified "Ajax" as opposed to standard form POST because it was specific.

You need something special? I'm new to Phalcon, and I like it! But I'm using some custom classes that extend Phalcon so that I can write more convenient overriden methods.



18.5k

Ah well. As far as I used AJAX POSTs, I didn't had to do nothing new: only the URL with the action, and pass a data object. Nothing special.

A workaround for your problem maybe would be creating a function that does manual trim to a $var argument, and call it in every action you use AJAX.