Re: updating a value when user clicks a link

2010-09-28 Thread james livsey
Hi

Well its during the creation of an advert that the relevant field in
appointments would need to be updated so it seemed like the best place to do
it

thanks

On Mon, Sep 27, 2010 at 7:19 PM, cricket zijn.digi...@gmail.com wrote:

 On Mon, Sep 27, 2010 at 10:24 AM, james livsey
 jamesliv...@googlemail.com wrote:
  Thanks Cricket,
 
  I added that code as you suggested. While it doesnt cause any errors it
  doesnt seem to modify the field data either.
 
  what I have is:
 
 function add($appointment_id = null){
 //existing code
 $this-Advert-Appointment-id = $appointment_id;
 $this-Advert-Appointment-saveField('appointment_status',
 'Order');
 $this-Advert-create();
 }
 
 
  does that look about right?
 
  And yeah your right i should change it to status
 
 You've got create() in the wrong place. That should come first, if
 it's included at all. See the API:

 http://api.cakephp.org/class/model#method-Modelcreate

 $this-Advert-Appointment-create(array('Appointment' = array('id'
 = $appointment_id)));

 That will initialize the instance with the appropriate id.

 Actually, why are you calling create() on Advert, instead of
 Appointment? I'm guessing there's more to this method.

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: updating a value when user clicks a link

2010-09-27 Thread james livsey
Thanks Cricket,

I added that code as you suggested. While it doesnt cause any errors it
doesnt seem to modify the field data either.

what I have is:

   function add($appointment_id = null){
   //existing code
   $this-Advert-Appointment-id = $appointment_id;
   $this-Advert-Appointment-saveField('appointment_status', 'Order');
   $this-Advert-create();
   }


does that look about right?

And yeah your right i should change it to status

On Fri, Sep 17, 2010 at 6:42 PM, cricket zijn.digi...@gmail.com wrote:

 On Fri, Sep 17, 2010 at 6:22 AM, james jamesliv...@googlemail.com wrote:
  Hi,
 
  I have a table that holds appointments and in view.ctp there is a link
  that allows the user to convert that appointment to an advert and
  passes the id of the appointment and the name of the business involved
  to the add.ctp view for adding an advert.
 
  When this happens i need an appointment_status field in the
  appointments table to update to Ordered. How can I do this? i cant
  seem to be able to include it in the save method of the add advert.

 Assuming there's an association between Advert and Appointment:

 $this-Advert-Appointment-id = $id;
 $this-Advert-Appointment-saveField('appointment_status', 'ordered');

 BTW, why don't you name the field just 'status'? Seems a bit redundant.

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: updating a value when user clicks a link

2010-09-27 Thread cricket
On Mon, Sep 27, 2010 at 10:24 AM, james livsey
jamesliv...@googlemail.com wrote:
 Thanks Cricket,

 I added that code as you suggested. While it doesnt cause any errors it
 doesnt seem to modify the field data either.

 what I have is:

    function add($appointment_id = null){
    //existing code
    $this-Advert-Appointment-id = $appointment_id;
        $this-Advert-Appointment-saveField('appointment_status', 'Order');
    $this-Advert-create();
    }


 does that look about right?

 And yeah your right i should change it to status

You've got create() in the wrong place. That should come first, if
it's included at all. See the API:

http://api.cakephp.org/class/model#method-Modelcreate

$this-Advert-Appointment-create(array('Appointment' = array('id'
= $appointment_id)));

That will initialize the instance with the appropriate id.

Actually, why are you calling create() on Advert, instead of
Appointment? I'm guessing there's more to this method.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: updating a value when user clicks a link

2010-09-17 Thread cricket
On Fri, Sep 17, 2010 at 6:22 AM, james jamesliv...@googlemail.com wrote:
 Hi,

 I have a table that holds appointments and in view.ctp there is a link
 that allows the user to convert that appointment to an advert and
 passes the id of the appointment and the name of the business involved
 to the add.ctp view for adding an advert.

 When this happens i need an appointment_status field in the
 appointments table to update to Ordered. How can I do this? i cant
 seem to be able to include it in the save method of the add advert.

Assuming there's an association between Advert and Appointment:

$this-Advert-Appointment-id = $id;
$this-Advert-Appointment-saveField('appointment_status', 'ordered');

BTW, why don't you name the field just 'status'? Seems a bit redundant.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en