Wiki

Clone wiki

khk-independent / Task view

The previous chapters were quite detailed. From now on you'll have to manage on your own. After all, the stated introduction to this project was that you'll have to Google quite a lot.

Don't be afraid to discuss the project in the Skype chatroom.

The Task controller

  • Create a new controller, Controller_Tasks

Deleting a task

Open the employee view we implemented in the previous chapter and try to delete a task using the Delete link - this should now work.

Adding a task

This ties in to the add task form we implemented in the employee view.

  • Add action_create_new
  • Load the $_POST parameters from the request (remember, this action is a target of a <form> submit)
$this->request->post('task');
  • Add a method to save the new task: Model_Task::create_new(array $form_data) {}
  • Implement the method, read up on basic ORM usage. The method should accept an array of form data (from the view, through Controller_Task) and create a new row in the tasks table
  • The Controller is responsible for displaying a notification message if the saving succeeded. Error messages should be shown when something went wrong
  • The flow should look like /employees/view/1 -> /tasks/create_new -> /employees/view/1 in other words the Task controller redirects back to the employee view the request came from
  • Don't worry about making it super-usable right now: no need to auto-fill the form fields again nor show what exactly went wrong

Editing a task

Task edit view

Editing a task is actually surprisingly similar to creating a new task. Some points to note:

  • The URL for editing a task should be /tasks/edit/<task-id>
  • The form should be filled in with the task info (new task creation form is empty by default)
  • Editing a task updates some specific row in the database, identified by the task ID. No new row is created.

Moving on

Next up: Dashboard view

Updated