Re: add in a field to a array with multiple records

2014-10-04 Thread ajt


To makes things clearer I can save multiple records at once. I can add 
fields to these records manually as I need to add additional fields that 
the user cant add in themselves.

The problem is also i dont want to save associated models and just 1 model, 
so saveAssociated is not what i want. I dont want to save 
availabilityfortutors

-- 
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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


add in a field to a array with multiple records

2014-10-03 Thread ajt
There has to be a simple answer but I cant add in a field to a array with 
multiple records . I can do it with a single records but multiple 
records are different. The below code doesnt allow me to save a record. I 
can use another save command and add the records but no extra fields. 

http://book.cakephp.org/2.0/en/models/saving-your-data.html

http://stackoverflow.com/questions/26161251/cant-save-data-from-1-table-to-another-table/26161699#26161699

 if ($this-request-is('post')) {
 $this-Availtmp-create();
 $Availtmp = array('Availtmp' = 
$this-request-data['AvailabilityForTutor']);
 
   $Availtmp[0]['Availtmp']['tutor_id'] = 2; //these fields I 
want to add in
   $Availtmp[1]['Availtmp']['tutor_id'] = 2;
$Availtmp[2]['Availtmp']['tutor_id'] = 2;

 debug($Availtmp) ;

   
 if ($this-Availtmp-saveAll($Availtmp)) {..
 //if 
($this-Availtmp-saveAll($this-request-data['AvailabilityForTutor']) 
){//this works

data
array(
'Availtmp' = array(
(int) 0 = array(
'weekday' = 'Monday',
'start_time' = array(
'hour' = '09',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '11',
'min' = '00',
'meridian' = 'pm'
),
'id' = '99'
),
(int) 1 = array(
'weekday' = 'Tuesday',
'start_time' = array(
'hour' = '09',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '10',
'min' = '00',
'meridian' = 'pm'
),
'id' = '100'
),
(int) 2 = array(
'weekday' = 'Wednesday',
'start_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'id' = '101'
),
(int) 3 = array(
'weekday' = 'Thursday',
'start_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'id' = '102'
),
(int) 4 = array(
'weekday' = 'Friday',
'start_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'id' = '103'
),
(int) 5 = array(
'weekday' = 'Saturday',
'start_time' = array(
'hour' = '09',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '11',
'min' = '00',
'meridian' = 'pm'
),
'id' = '104'
),
(int) 6 = array(
'weekday' = 'Sunday',
'start_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'end_time' = array(
'hour' = '12',
'min' = '00',
'meridian' = 'am'
),
'id' = '105'
)
),
(int) 0 = array(
'Availtmp' = array(
'tutor_id' = (int) 2
)
),
(int) 1 = array(
'Availtmp' = array(
'tutor_id' = (int) 2
)
),
(int) 2 = array(
'Availtmp' = array(
'tutor_id' = (int) 2
)
)
)

-- 
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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at