Jump to content

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 comment
https://forums.phpfreaks.com/topic/128468-solved-cake-php-help/
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 comment
https://forums.phpfreaks.com/topic/128468-solved-cake-php-help/#findComment-666443
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.