Re: Where to put function needed in multiple models?

2009-09-23 Thread kdubya
Jon, OK, I got it working as a behavior. I had to make 3 changes from your suggestion to get it to work: 1) The actAs declaration had to be: var $actsAs = array('Cleanup'=>array('field1'=>'', 'field2'=>'')); // i.e. empty options value for each field (Actually, since I'm not using any options,

Re: Where to put function needed in multiple models?

2009-09-23 Thread kdubya
Jon, On Sep 22, 6:27 pm, Jon Bennett wrote: > Hi kdubya, > > Sounds like a perfect candidate for a behaviour to me. I had attempted to go down this behavior path but it seemed much more complicated than necessary. Your example looks pretty complete so I'll give it a try (may as well try to

Re: Where to put function needed in multiple models?

2009-09-22 Thread Jon Bennett
Hi kdubya, > I'm trying to follow the structure of CakePHP but I don't know where > to put a utility function that I would like to call to filter certain > fields in more than one Model. > > The utility function filters most HTML tags, but allows some safe ones > like etc. and replaces newlines

Re: Where to put function needed in multiple models?

2009-09-22 Thread kdubya
Thank you, Brian. Sounds like an excellent suggestion! (Why didn't I think of that?) On Sep 22, 4:54 pm, brian wrote: > If calling from beforeSave(), the best place might be AppModel. If you > don't already have one of those, copy the file at > cake/libs/models/app_model.php to your app director

Re: Where to put function needed in multiple models?

2009-09-22 Thread brian
If calling from beforeSave(), the best place might be AppModel. If you don't already have one of those, copy the file at cake/libs/models/app_model.php to your app directory (not app/models) and modify that. You would then call the function from within your own model as $this->yourFunction(...).

Where to put function needed in multiple models?

2009-09-22 Thread kdubya
I'm trying to follow the structure of CakePHP but I don't know where to put a utility function that I would like to call to filter certain fields in more than one Model. The utility function filters most HTML tags, but allows some safe ones like etc. and replaces newlines with . I want to call