Monday, September 27, 2010

Re: updating a value when user clicks a link

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.digital@gmail.com> wrote:
On Fri, Sep 17, 2010 at 6:22 AM, james <jameslivsey@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+unsubscribe@googlegroups.com For 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: