Monday, July 23, 2012

Re: How to pass id through a form to another controller and view form

Hi, 
Thanks this works almost perfectly apart from it is not echoing out the value in the hidden field :S it just leaves it blank, any idea why?

On Sunday, 22 July 2012 19:20:30 UTC+1, cricket wrote:
On Sun, Jul 22, 2012 at 8:19 AM, Guti Grewal <gutigrewal@gmail.com> wrote:
>
> What I want to do is get the galleryid to be inserted into the images table,
> through a form, which you can see above once a gallery is added it redirects
> to images/add, I want to get the last inserted id into the form in the
> images/add form so that I am able to call on the related ones

$this->redirect(
        array(
                'controller' => 'images',
                'action' => 'add',
                'gallery_id' => $this->Gallery->getInsertID()
        )
);


Route::connect(
        '/images/add/:gallery_id',
        array(
                'controller' => 'images',
                'action' => 'add'
        ),
        array(
                'gallery_id' => '[0-9]+'
                'pass' => 'gallery_id'
        )
);

public function add($gallery_id = null)
{
        $this->set(compact('gallery_id'));
        ...
}

$this->Form->hidden('Image.gallery_id', array('value' => $gallery_id));

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: