Jump to content

[SOLVED] cake php help


sasori

Recommended Posts

am a noob and i need help in cake php.. i dont' know how to fix this error

 

91jead.png

 

here's my codes

 

//task.php
<?php
class Task extends AppModel{
  var $name = 'Task';
}
?>

//class TaskController

<?php
class TasksController extends AppController{
    var $name = 'Tasks';
    var $helpers = array('Html','FORM');

    function index(){
      $this->set('tasks',$this->Task->find('all'));
    }

    function add(){
      if(!empty($this->data)){
        $this->Task->create();
        if($this->Task->save($this->data)){
          $this->Session->setFlash('The Task has been saved');
          $this->redirect(array('action'=>'index'),null,true);
        }else{$this->Session->setFlash('Task not saved. Try again.');}
      }
    }
}


?>



//add.ctp
<?php echo $form->create('Task');?>
<fieldset>
<legend>Add New Task</legend>
<?php
echo $form->input('title');
echo $form->input('done');
?>
</fieldset>
<?php echo $form->end('Add Task');?>

//index.ctp
<h2>Tasks</h2>
<?php if(empty($tasks)): ?>
    There are no tasks in this list
    <?php else: ?>
    <table>
        <tr>
            <th>Title</th>
            <th>Status</th>
            <th>Modified</th>
            <th>Actions</th>
        </tr>
        <?php foreach($tasks as $task): ?>
        <tr>
            <td>
                <?php echo $task['Task']['title'] ?>
            </td>
            <td>
                <?php if($task['Task']['done']) echo "Done";
                      else echo "Pending";
                ?>
            </td>
            <td>
            <?php
                echo $task['Task']['created']
            ?>
            </td>
            <td>
                <?php echo $task['Task']['modified'] ?>
            </td>
            <td>
                <!-- actions on tasks will be added later -->
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

when i point browser to localhost/cooktoodoo/task/add

that screenshot appears :(

Link to post
Share on other sites

I haven't used cakephp before, but try renaming the f_o_r_m.php file as the class name in it, which will be FORM in your case. Better yet, rename the class FormHelper and the filename Form.php. Hope that helps.

Link to post
Share on other sites

I haven't used cakephp before, but try renaming the f_o_r_m.php file as the class name in it, which will be FORM in your case. Better yet, rename the class FormHelper and the filename Form.php. Hope that helps.

 

No, that's not it.

 

Use 'Form' in your $helpers array, not FORM.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.