so I have two models, family and students, each family could have several students. I want to use one view (edit view for family) for both family and students editing.
-- <!-- File: /app/View/Families/edit.ctp -->
<h1>Edit family</h1>
<?php echo $this->Form->create('Family'); ?>
<table>
<?php echo $this->Form->input('id', array('type'=>'hidden')); ?>
<tr> <td> <?php echo $this->Form->input('father'); ?> </td>
<td> <?php echo $this->Form->input('mother'); ?> </td> </tr>
<tr> <td> <?php echo $this->Form->input('address'); ?> </td>
<td> <?php echo $this->Form->input('zip'); ?> </td> </tr>
<tr> <td> <?php echo $this->Form->input('phone'); ?> </td>
<td> <?php echo $this->Form->input('email'); ?> </td> </tr>
<?php foreach ($students as $student): ?>
<tr> <td> <?php echo $this->Form->input('Student.Name'); ?> </td>
<td> <?php echo $this->Form->input($student['Student']['Birthday']); ?> </td>
</tr>
<?php endforeach;?>
<?php echo $this->Form->end('Save Post'); ?>
I can see the current value for family model in the form but, it does not show the current student info in the form.
"CakePHP will assume that you are editing a model if the 'id' field is present in the
data array. If no 'id' is present (look back at our add view), CakePHP will assume that you are inserting a
new model when save() is called."
So I guess I am missing this portion "id" field for the second model "student". but the "student" table has a "family_id" referencing back to the "id" field of "family' table
So how I can fix this?
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+unsubscribe@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.
No comments:
Post a Comment