Hi, thanks both for your replies.

@Alexandru: Unfortunately that's not flexible enough for me, because
depending on where I'm coming from I may or may not want to pre-
populate a field.

@brian: I usually do it something like /project_images/add/project_id:
3 but that means I have to write logic at the URL generation stage and
also at the controller method stage, but with the code above I only
have to think about it at the URL generation stage, less room for
error I think (and faster)!






On Dec 15, 6:32 pm, brian <[email protected]> wrote:
> On Mon, Dec 15, 2008 at 1:18 PM, acoustic_overdrive
>
>
>
> <[email protected]> wrote:
>
> > I just thought of a little function that I wanted to get some feedback
> > on. It's a way to pre-populate a form when adding new records, using
> > the URL only and no controller-specific controller logic.
>
> > In AppController::beforeRender :
>
> > if(isset($_REQUEST['populate'])) {
> >        if(empty($this->data)) {
> >                $this->data = array();
> >        }
> >        $this->data = array_merge_recursive($this->data,$_REQUEST
> > ['populate']);
> > }
>
> > then make a link pointing to an ADD form:
>
> > /admin/project_images/add?populate[ProjectImage][project_id]=3&populate
> > [ProjectImage][name]=blah
>
> > What do you think? Not very cakey with that querystring but is there a
> > better way to do this?
>
> Why not just pass the Project.id (I'm assuming this request is coming
> from a Project page) and fetch and add any data to $this-data in your
> add() method?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to