/** * The form handler for AddListForm * * @param array $rawData * @param Form $form * @param SS_HTTPRequest $request */ public function doAddNewList($rawData, $form, $request) { $list = TodoList::create(); $form->saveInto($list); $list->write(); $this->redirectBack(); }
$data = (array) json_decode($data); $data['user_id'] = $user_id; // Connect TodoList class include 'todoClass.php'; if ($data) { $list = new TodoList($data); if ($method != '') { switch ($method) { case 'setName': $sth = $list->write('name', $list->name); break; case 'setDeadline': $sth = $list->write('deadline', $list->deadline); break; case 'create': $sth = $list->create(); break; case 'delete': $sth = $list->delete(); break; } if ($method == 'getLast') { echo $list->getLast($db); return false; } if (!$db->exec($sth)) { echo "Error width {$sth}"; return false; } else { echo "success {$method}"; }