yep sweet!! needs some refinement but sweet it works.
happy baking - S
On 02/04/2008, grigri <[EMAIL PROTECTED]> wrote:
>
>
> If you can assume that the settings in actsAs are valid, you can do
> this:
>
> class Photo extends AppModel {
> var $actsAs = array(
> 'Upload' => array('some' => 'settings')
> );
>
>
> function save($data = null, $validate = true, $fieldList = array())
> {
>
> // Prepare new config
> $config = array_merge(
> $this->actsAs['Upload'],
> array(
> 'src' => array(
>
> 'dir' => '/' . $this->getEventSlug($this->data['Photo']
> ['event_id'])
>
> )
> )
> );
> // Detach behavior
> $this->Behaviors->detach('Upload');
> // Re-attach with new params
> $this->Behaviors->attach('Upload', $config);
> // Continue saving normally
>
> return parent::save($data, $validate, $fieldList);
> }
> }
>
>
> On Apr 2, 3:32 pm, "Sam Sherlock" <[EMAIL PROTECTED]> wrote:
> > but from where do I call the attach detach?
> >
> > here is what I am planning to try
> >
> > - read the setting of Upload behavior to an array
> > - update the dir setting
> > - detach the set behaviour
> > - attach the modified one
> >
> > where do I use the attach / detach behaviour calls??
> >
>
> > On 02/04/2008, grigri <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Since the introduction of the behaviors collection, I don't think the
> > > code in that article will work as it relies on the behavior objects
> > > being properties of the model, which they aren't any more.
> >
> > > Behaviors can be attached/detached at runtime with the `attach` and
> > > `detach` methods, but reconfiguring depends entirely on the behavior
> > > implementation itself.
> >
> > > On Apr 2, 2:40 pm, "[EMAIL PROTECTED]"
> >
> > > <[EMAIL PROTECTED]> wrote:
> > > > This might be useful to you. It allows you reconfigure the
> behaviours
> > > > as well.
> >
> > > >
> http://www.sanisoft.com/blog/2007/06/26/attach-detach-behaviors-at-ru...
> >
> > > > Simonhttp://www.simonellistonball.com/
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---