my problem goes this way: im trying to do a multiple save at once but before i did, i checked the resulting array every after a form submit with different values on it and i found out that the resulting array of data seems a little bit wierd. so first: heres my rel:
OfferedSubject HABTM Course heres my view: <?php $session->flash(); ?> <div class="offeredSubjects form"> <?php echo $ajax->form(array( 'type' => 'post', 'options'=>array( 'url'=>array( 'controller'=>$this->params['controller'], 'action'=>'offeredSubjectAdd'.'/'.$subjectId.'/'.$lastSec.'/'. $numSec ), 'model'=>'OfferedSubject', 'update'=>'results' ) )); ?> <fieldset> <legend><?php __('Add OfferedSubject');?></legend> <table cellpadding="0" cellspacing="0"> <tr> <th><?php echo __('Subject Id');?></th> <th><?php echo __('Subject');?></th> <th><?php echo __('Section');?></th> <th><?php echo __('Description');?></th> <th><?php echo __('Lab Units');?></th> <th><?php echo __('Lecture Units');?></th> <th><?php echo __('Days');?></th> <th><?php echo __('Times');?></th> <th><?php echo __('Room');?></th> <th><?php echo __('Limit');?></th> <th><?php echo __('Exclusive Gender');?></th> <th><?php echo __('College');?></th> <th><?php echo __('Exclusive Course');?></th> </tr> <?php $i = 0; $j = 0; while ($i<$numSec){ $class = null; if ($i++ % 2 == 0) { $class = ' class="altrow"'; } ?> <tr <?php echo $class;?>> <td> <?php echo $subjects['Subject']['id']; ?> </td> <td> <?php echo $subjects['Subject']['code']; ?> </td> <td> <?php echo $form->input($j.'.section'); ?> </td> <td> <?php echo $subjects['Subject']['name']; ?> </td> <td> <?php echo $subjects['Subject']['lab_units']; ?> </td> <td> <?php echo $subjects['Subject']['lecture_units']; ?> </td> <td> <?php echo $form->input($j.'.days'); ?> </td> <td> <?php echo $form->input($j.'.times'); ?> </td> <td> <?php echo $form->input($j.'.room'); ?> </td> <td> <?php echo $form->input($j.'.limits'); ?> </td> <td> <?php echo $form->input($j.'.gender_flag',array( 'type'=>'select', 'options'=> array( 'M'=>'M', 'F'=>'F' ), 'empty'=>'Choose One' ) ); ?> </td> <td> <?php echo $form->input($j.'.college_id');?> </td> <td> <?php echo $form->input('Course'); ?> </td> </tr> <?php $j++;} ?> </table> </fieldset> <?php echo $form->end('Submit');?> </div> ------------------------------------------------------------------------------------- ok $numSec there is used to count how many OfferedSubjects will i save... say for instance i wanted to save 4 OfferedSubjects without choosing any Course first heres the resulting array: 4 OfferedSubjects without choosing any Course: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => 1 [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => [1] => [2] => ) ) ) As you can see, there are only three Course reflected ---------------------------------------------------------------------- heres another resulting array: 4 OfferedSubjects choosing 1 Course from the 4th OfferedSubject-Course View: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => 1 [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => [1] => [2] => 1 ) ) ) as you can see, instead of having the value 1 in $data['Course'] ['Course'][3] it is placed in $data['Course']['Course'][2] which is wrong. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- heres another resulting array: 4 OfferedSubjects choosing 2 Course from the 3rd OfferedSubject-Course View: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => 1 [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => [1] => 1,3 [2] => ) ) ) as you can see,same as the previous result, instead of having the value 1,3 in $data['Course']['Course'][2] it is placed in $data ['Course']['Course'][1] which is wrong and again the last index (which is 3) is not shown.. ------------------------------------------------------------------------------------------------------------- BUT! heres another resulting array: 4 OfferedSubjects choosing 1 Course from the 1st OfferedSubject-Course View: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => 1 [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => 1 [1] => [2] => [3] => ) ) ) AND heres another resulting array: 4 OfferedSubjects choosing 2 Course from the 1st OfferedSubject-Course View: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => 1 [1] => 3 [2] => [3] => [4] => ) ) ) instead of having data['Course']['Course'][0]=>1,3 the value of 3 is being forwarded to index 1.. ---------------------------------------------------------------------------------------- and lastly heres the result when im trying to choose 2 Course from each of the 4 OfferedSubject-Course view: Array ( [OfferedSubject] => Array ( [0] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [1] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [2] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) [3] => Array ( [section] => [days] => [times] => [room] => [limits] => [gender_flag] => [college_id] => 1 ) ) [Course] => Array ( [Course] => Array ( [0] => 1 [1] => 3 [2] => 1,3 [3] => 1,3 [4] => 1,3 ) ) ) ---------------------------------------------------------------------------- so based on 4 OfferedSubject-Course my findings are: 1. results only 3 elements of Course if the first Course(which is $data['Course']['Course'[0]]) is not chosen. 2. results correct number of elements(which is 4 in the example) if i choose 1 from the first Course(which is $data['Course']['Course'[0]]). 3. results 5 elements of Course if i choose 2 from the first Course (which is $data['Course']['Course'[0]]). guys,im really lost right now..how can i solve this one, any idea? Please help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---