both the title of the todo and any number of the todos (if the task
has any) in one form. The form as you can see below submits to the
task edit action. But when I submit the form, only the title of the
task is updated, but not the titles of the todos. Am I supposed to be
handling the save of the todos myself in the edit action? The
association are already set in the model, such $belongsTo and
$hasMany. Any ideas on what I should do here?
Here's my code for the form.
e($form->create('Task', array('controller' => 'task', 'action' =>
"edit/{$task['Task']['id']}", 'class' => 'form')));
e($form->hidden('Task.id', array('value' => $task['Task']['id'])));
e($form->text('Task.title', array('value' => $task['Task']['title'],
'class' => 'long')));
<?php foreach($task['Todo'] as $todo): ?>
<li>
<?php e($form->text("{$todo['id']}.Todo.id", array('value'
=> $todo['title'], 'class' => 'long'))); ?>
</li>
<?php endforeach; ?>
e($form->submit('Edit'));
e($form->end());
Here's a snippet of the save code I am calling.
if($this->Task->saveAll($this->data['Task'])){
$this->Session->setFlash('The task has been updated', 'default',
array('class' => 'information'));
$this->redirect(array('action' => 'show', $id));
}
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment