(This information is current as of Cake 1.2, SVN revision #4567).
A reference to the model object is always the first parameter to a
behavior method. Any other parameters you pass to it come after, so
$text would be the second parameter. The proper method definition
would therefore be:
function stripText(&$model, $text) {
....
}
On Mar 3, 2:53 am, "Zoltan" <[EMAIL PROTECTED]> wrote:
> I'm trying to move some processing into a behavior.
>
> What I've done so far is, create a file called placehelper.php (in the
> model/behaviors dir) like:
> class placehelperBehavior extends ModelBehavior
> {
>
> function setup(&$model, $config = array()) {
>
> }
>
> function stripText($text)
> {
> print 'text: ' . $text; // gives 'Object of class Place could
> not be
> converted to string' error
> }
> ...
>
> My controller has something like:
> $sName = $this->data['Place']['name'];
> print '$sName: '. $sName. '<br>';
> $this->data['Place']['profile_url'] = $this->Place->stripText($sName);
> die();
>
> and the model is like:
> class Place extends AppModel {
>
> var $name = 'Place';
> var $actsAs = array('placehelper');
> ...
>
> So right now it seems to get the data, but instead of just passing the
> text field, it seems to be passing the whole places object (this is
> what it seems if I do a print_r on what is passed into the stripText
> method.
>
> My question is, How do I pass data from the controller to the Model's
> behaviors and then get it back?
>
> Thanks, Zoltan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---