Hello Google CakePHP Group,

I'm stumped and thought I'd submit. I'm wanting to create multiple
task list and related task on a single view. This view also has
multiple forms created using $ajax->form and $ajax->submit that will
let me add task to their related tasklist. For some reason that I
cannot figure out $this->data['Task']['title'] is only set on the
first form and not on any of the following forms.

Here is the code for my view:

[code]
<h1>Task Lists</h1>
<div class="action">
        <ul>
                <li><?php echo $html->link('Create Tasklist',
array('controller'=>'tasklists', 'action'=>'add', $projects['Project']
['id'])); ?></li>
        </ul>
</div>
<?php
foreach($projects['Tasklist'] as $tasklist) :
        echo "<h3>".$tasklist['tasklist']."</h3>\n";
        echo "<hr />\n";

        echo $ajax->div('current_list_'.$tasklist['id'],
array('class'=>'currentTasklist'))."\n";

        for ($i=0; $i < count($tasklist['Task']); $i++) {
                $task = $tasklist['Task'][$i];
                if($task['done'] == 0) {
                        echo $ajax->div('current_'.$task['id'],
array('class'=>'task'))."\n";
                        echo '<input id="current_check_'.$task['id'].'" 
type="checkbox"
onClick="new Ajax.Updater(\'complete_list_'.$tasklist['id'].'\',\'/
projects/taskclose/'
                                .$task['id'].'/'.$tasklist['id'].'\', 
{asynchronous:true,
evalScripts:true});new Effect.Fade(\'current_'.$task['id'].'\');" />
'."\n";
                        echo $form->label(null, $task['title'],
array('for'=>'current_check_'.$task['id']))."\n";
                        echo $ajax->divEnd('current_'.$task['id'])."<!--// end
div.current_".$task['id']." -->\n";
                }
        }
        echo $ajax->divEnd('current_list_'.$tasklist['id'])."<!--// end
div.current -->\n";
?>
<div class="addTaskFormWrap">
        <?php
        echo $html->link('Add Task', 'javascript:;',
array('onclick'=>"Element.toggle('add_tasklist_".
$tasklist['id']."')"))."\n";
        ?>
        <?php
                echo $ajax->div('add_tasklist_'.$tasklist['id'],
array('class'=>'addTaskForm', 'style'=>'display: none;'))."\n";
                echo $ajax->form('taskadd/'.$projects['Project']['id'].'/'.
$tasklist['id'], 'post', array('update'=>'current_list_'.
$tasklist['id']))."\n";
                echo $form->input('Task.title_'.$tasklist['id'],
array('id'=>'TaskTitle_'.$tasklist['id']))."\n";
                echo $ajax->submit('Add Task', 
array('url'=>'/projects/taskadd/'.
$projects['Project']['id'].'/'.$tasklist['id'],
'update'=>'current_list_'.$tasklist['id']))."\n";
                echo $ajax->divEnd('add_tasklist_'.$tasklist['id'])."<!--// end
id.add_tasklist_".$tasklist['id']." -->\n";
        ?>
<?php
        echo $ajax->div('complete_list_'.$tasklist['id'],
array('class'=>'completeTasklist'))."\n";

        for($i=0; $i < count($tasklist['Task']); $i++) {
                $task = $tasklist['Task'][$i];
                if($task['done'] == 1) {
                        echo $ajax->div('complete_'.$task['id'],
array('class'=>'task'))."\n";
                        echo '<input id="complete_check_'.$task['id'].'" 
type="checkbox"
onClick="new Ajax.Updater(\'current_list_'.$tasklist['id'].'\',\'/
projects/taskopen/'
                                .$task['id'].'/'.$tasklist['id'].'\', 
{asynchronous:true,
evalScripts:true});new Effect.Fade(\'complete_'.$task['id'].'\');"
checked="yes" />'."\n";
                        echo $form->label(null, $task['title'],
array('for'=>'complete_check_'.$task['id']))."\n";
                        echo $ajax->divEnd('complete_'.$task['id'])."<!--// end
div.complete_".$task['id']." -->\n";
                }
        }
        echo $ajax->divEnd('complete_list_'.$tasklist['id'])."<!--// end
div.complete -->\n";
?>
<?php endforeach; ?>
[/code]

Here is the code for my controllers action:
[code]
        public function taskadd($project_id = null, $tasklist_id = null) {
                $this->layout = 'ajax';
                $this->Tasklist->recursive = 1;
                die(pr($this->params));
                die(pr($this->data));

                if (!$project_id && !$tasklist_id) {
                        $this->Session->setFlash('Invalid Project.');
                        $this->redirect(array('action','tasklists'), null, 
true);
                }

                if(isset($tasklist_id)) {
                        $this->data['Task']['tasklist_id'] = $tasklist_id;
                        $this->data['Task']['done'] = 0;
                        die(pr($this->data));
                }
                else {
                        $this->Session->setFlash('Invalid Project.');
                        $this->redirect(array('action'=>'tasklists'), null, 
true);
                }

                if (!empty($this->data)) {
                        $this->cleanUpFields();
                        $this->Project->recursive = 2;
                        if($this->Task->save($this->data)) {
                                $this->set('current_tasklist', 
$this->data['Task']
['tasklist_id']);
                                $this->set('tasklist', 
$this->Tasklist->read(null, $this-
>data['Task']['tasklist_id']));
                                $this->render('current', 'ajax');
                        }
                }
        }
[/code]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to