That is an odd error - an undefined function and then showing a
variable ?
Can you show me the code you are using?
BTW : $html->link('/leads/addactivity/'.$lead['Lead']['id']); Should
have been $html->link("Add Acrivity", '/leads/addactivity/'.
$lead['Lead']['id']);
On Jun 15, 2:40 am, Amy1234 <[EMAIL PROTECTED]> wrote:
> I am using the stable cake release 1.1
>
> I used the link exactly a you provided in your tutirual (thnk you very
> much for that!)
>
> when I did that I got a undefined function: $Lead_id in '/activitoes/
> add'
>
> Thanks fo your help
> Amy
>
> On Jun 13, 9:28 pm,GeoffFord<[EMAIL PROTECTED]> wrote:
>
> > What exactly was the link that you used? And the code for the hidden
> > form field as well?
>
> > And which version of Cake?
>
> > On Jun 14, 10:12 am, Amy1234 <[EMAIL PROTECTED]> wrote:
>
> > > 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,GeoffFord<[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
-~----------~----~----~----~------~----~------~--~---