As my post states, I do not believe you can save multiple
OfferedSubject at once, each having their own HABTM Course. You would
need to create a form which produces an array as shown above.
Now I am have no idea about your schema as your form obviously
includes data from Subject and Section models which you have not
mentioned, it would be be helpful to know more about your schema, it's
associations, the controller action which passes the data to this view
and possibly a link to see the form online.
However, I will attempt to give you an idea of what you're trying to
achieve (this assumes your passing a $OfferedSubjects array from the
controller which contains a row for each OfferedSubject).
<?php foreach($OfferedSubjects AS $key => $value): ?>
<tr <?php echo $class;?>>
<td><?php echo $value['Subject']['id']; ?></td>
<td><?php echo $value['Subject']['code']; ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.section'); ?></td>
<td><?php echo $value['Subject']['name']; ?></td>
<td><?php echo $value['Subject']['lab_units']; ?></td>
<td><?php echo $value['Subject']['lecture_units']; ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.days'); ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.times'); ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.room'); ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.limits'); ?></td>
<td><?php echo $form->input($key.'.OfferedSubject.gender_flag',array
(
'type'=>'select',
'options'=>array('M'=>'M','F'=>'F'),
'empty'=>'Choose One'
));?></td>
<td><?php echo $form->input($key.'.OfferedSubject.college_id');?></
td>
<td><?php echo $form->input($key.'.OfferedSubject.Course'); ?></td>
</tr>
<?php endforeach; ?>
I'm not sure how the automagic will behave when prefixing field names
with the numerical array key, but the above would output the right
data array that could then be looped through in the controller calling
saveAll() for each OfferedSubject saving it's HABTM Course at the same
time.
Doing this alone is fairly advanced for a CakePHP newbie, then taking
into account the fact your submitting this via Ajax ups the
complication further, good luck!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---