Hi there ...
Is there a way to get this work? If i run this, the related data is
saved, but the todo_id is missing. If I use the same with a single
field the todo_id field is added ...
todo.php
------------------------------
<?php
class Todo extends AppModel
{
var $name = 'Todo';
var $hasMany = array('Task');
}
?>
task.php
------------------------------
<?php
class Task extends AppModel
{
var $name = 'Task';
var $belongsTo = array('Todo');
}
?>
todos_controller.php
------------------------------
<?php
class TodosController extends AppController {
var $name = 'Todos';
function add() {
if (!empty($this->data)) {
$this->cleanUpFields();
$this->Todo->create();
if ($this->Todo->saveAll($this->data)) {
} else {
}
}
}
}
?>
todos/add.ctp
------------------------------
<div class="todos form">
<?php echo $form->create('Todo');?>
<fieldset>
<legend><?php __('Add Todo');?></legend>
<?php
echo $form->input('Todo.name');
?>
</fieldset>
<fieldset>
<legend><?php __('Add Tasks for todo');?></legend>
<?php
echo $form->input('Task.1.name');
echo $form->input('Task.2.name');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---