Quick reply! Got a meeting in 2 minutes...
Process Person::add() as normal, once you call
$this->Person->save($this->data); call $id = $this->Person->id; (The id of
the last inserted row)
Then do $this->redirect(array('controller' => 'subordinates', 'action' =>
'add', $id)); (/subordinates/add/<id>) (function add($id=null) { .. } )
In subordinates, check if $id is set and if it's a valid person, if so -
find the persons name, add it to your view for the user to see they are
adding subordinates to that particular person.
Have the form submit to the same URL (/subordinates/add/<id>) and when
saving it, if the id is present manually do
$this->data['Subordinate']['person_id'] = $id;
Hope that made sense!
On 1 March 2012 11:56, driss bounouar <[email protected]> wrote:
> I have two models person and subordinate and I have the relationship
> person has many subordinate what I want to do is that when I add the
> person when I click the submit button I will be redirected to add
> subordinate to that exact person I don't want a combox to choose between
> people ??
>
> How could I do that ? and more specifically how could I hold the person Id
> and save it in the foreign key of subordinate ??
>
> I hope you understand what I mean
>
> thank you all
>
> --
> 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
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
--
Kind Regards
Stephen
http://www.ninjacodermonkey.co.uk
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php