thank you for your response, however when I did that as the link on my
leads/view I got an error...function addactivity() not defined in
leads controller,
I searchrd through the manual and found this "If the ID for the post
is at $post['Post']['id']...
<?php echo $html->hidden('Comment/post_id', array('value' =>
$post['Post']['id'])); ?>
Done this way, the ID for the parent Post model can be accessed at
$this->data['Comment']['post_id'], and is all ready for a simple $this-
>Post->Comment->save($this->data) call.
These same basic techniques will work if you're saving multiple child
models, just place those save() calls in a loop (and remember to clear
the model information using Model::create())."
But I don't understand it
Thanks
Amy
On Jun 13, 7:03 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
> To pass the lead id the link should be
>
> $html->link('/leads/addactivity/'.$lead['Lead']['id']); // assuming
> this is in your view.ctp/thtml
>
> Any values in the url after the controller/action will be passed into
> the action as paramerter so urls are in the format
>
> site.com/controller/action/param1/param2/param3 etc
>
> I couldn't find this in the manual just now. Hmmm...
>
> On Jun 14, 7:21 am, Amy1234 <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I am trying to build an application. The parent is leads and the
> > child association is activity.
>
> > everything is linked okay.
>
> > when I view a lead I can add a new activity. When I press new activity
> > it takes me to the new activity page. How do I get the lead_id that I
> > pressedd the new activity link to go automatically and register the
> > lead_id in the activity table.
>
> > I changed the lead controller to:
>
> > <?php
> > class LeadsController extends AppController {
>
> > var $name = 'Leads';
> > var $uses = array('Lead', 'Activity');
> > var $helpers = array('Html', 'Form' );
>
> > function index() {
> > $this->Lead->recursive = 0;
> > $this->set('leads', $this->Lead->findAll());
> > }
>
> > function view($id = null) {
> > if(!$id) {
> > $this->flash('Invalid id for Lead', '/leads/index');
> > }
> > $this->set('lead', $this->Lead->read(null, $id));
> > }
>
> > function add() {
> > if(empty($this->data)) {
> > $this->set('users',
> > $this->Lead->User->generateList());
> > $this->Lead->save($this->data);
> > $lead_id = $this->Lead->getLastInsertId();
>
> > $this->render();
> > } else {
> > $this->cleanUpFields();
> > if($this->Lead->save($this->data)) {
> > $this->data['activity']['lead_id'] =
> > $lead_id;
> > $this->flash('Lead saved.', '/leads/index');
> > } else {
> > $this->set('users',
> > $this->Lead->User->generateList());
> > $this->Lead->Activity->save($this->data);
> > }
> > }
> > }
>
> > function edit($id = null) {
> > if(empty($this->data)) {
> > if(!$id) {
> > $this->flash('Invalid id for Lead',
> > '/leads/index');
> > }
> > $this->data = $this->Lead->read(null, $id);
> > $this->set('users',
> > $this->Lead->User->generateList());
> > } else {
> > $this->cleanUpFields();
> > if($this->Lead->save($this->data)) {
> > $this->flash('Lead saved.', '/leads/index');
> > } else {
> > $this->set('users',
> > $this->Lead->User->generateList());
> > }
> > }
> > }
>
> > function delete($id = null) {
> > if(!$id) {
> > $this->flash('Invalid id for Lead', '/leads/index');
> > }
> > if($this->Lead->del($id)) {
> > $this->flash('Lead deleted: id '.$id.'.',
> > '/leads/index');
> > }
> > }
>
> > }
>
> > function addactivity($lead_id)
> > {
> > if (!empty($this->data))
>
> > {
>
> > $this->data['activity']['lead_id'] = $lead_id;
> > $this->Lead->Activity->save($this->data);
> > }
>
> > }
>
> > ?>
>
> > What else do I need to do to have the lead_id automatically transfer
> > to the new activity screen.
>
> > Also I would like the lead_id to be inserted via a hidden field.
>
> > Thanks
> > For your help
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---