In your code you are already using $stop as an array:
$this->set('stop',$stop['Leave']['event_stop_time']);
so when you try to calculate the $hours, then you have an array - a value :)
Try and fix that!
Enjoy, John
On Friday, 23 October 2015 12:43:47 UTC+3, Para K wrote:
>
> I'm working on a project for Payroll Dept. I have included inline editing
> feature in my code.
>
> When the user edits start date, the program should calculate and update
> the hours field by subtracting the stop date from start date. I'm stuck on
> the calculation part giving an error "Unsupported Operand Types". Below is
> my code snippet
>
> case 'event_date':
>
> if ($this->request->data['Leave']['event_date'] == $value) {
>
> $stop = $this->Leave->find('first', array('conditions'
> => array('event_date' => $value)));
> $this->set('stop',$stop['Leave']['event_stop_time']);
>
> $start = $this->request->data['Leave']['event_date'];
>
> $hours = ($stop - $start);
> $this->request->data['Leave']['hours'] = $hours;
> $this->set('updated_value', $hours);
>
> }
>
> Any form of help is much appreciated as I'm a newbie to cakephp
>
> Thanks
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.