http://pastebin.co.uk/13204
Usage: Place method in your app_model and call with the beforeValidate callback also placed in your app_model function beforeValidate() { $this->__sanitize($this->data); return true; } In every model of your app include the var $allowedChars = array(); In this array name any fields for which special characters must be allowed adn what those special characters are. The method includes some "shortcuts" and you can combine multiple shortcuts etc to get the desired outcome. Differences from usage guidelines in my previous post are: 1) You can flag a field to be ignored (will be returned without being passed through Sanitize::paranoid - essential for file uploads! 2) A "serialized" shortcut has been introduced that automatically inserts all the characters you need for a serialized field into the paranoid function. Simple usage example: var $allowedChars = array('emailfield' => array('.', '@', '-', '_')); Complex usage example: var $allowedChars = array('emailfield' => array('default'), 'descriptionfield' => array('default', 'textarea', 'markdown', '|')); Shortcuts are: default = basic chars used in most text fields including spaces, punctuation etc; datetime = basic chars used in datetime fields (' ', '-', ':') textarea = allows line breaks to be passed through markdown = for use when using markdown markup in your fields (nothing avaialble for textile Im afraid) serialized = for use when trying to save a set of serialized data. Special shortcut Ignore = doesnt send the field through paranoid and returns it "as is". So far I have used that only for file upload fields. Warnings: Because of the way this method is called it will onyl work when saving data and when the data validation callback is called. It will not work when using inputs to search the database and it will not work if beforeValidate is not called (e.g. saveField method by default does not call beforeValidate). All use is entirely at your own risk I'm afraid... Let me know what you think or any improvements you can come up with. Ian On Apr 18, 7:20 pm, Poncho <[EMAIL PROTECTED]> wrote: > Hey Ian, > > That code looks pretty nice, could you post the newer version you > mentioned? > > Cheers; > Poncho --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---