public function testUnavailableReasonRequired() { $test = new OphTrOperationbooking_Operation_Session(); $basic_attrs = array('sequence_id' => 1, 'date' => '2014-04-03', 'start_time' => '08:30', 'end_time' => '13:30', 'theatre_id' => $this->theatres('th1')->id); $test->attributes = $basic_attrs; $test->available = false; $this->assertFalse($test->validate()); $errs = $test->getErrors(); $this->assertArrayHasKey('unavailablereason_id', $errs); }
public function actionAddSession() { $session = new OphTrOperationbooking_Operation_Session(); $errors = array(); if (!empty($_POST)) { $session->attributes = $_POST['OphTrOperationbooking_Operation_Session']; if (!$session->save()) { $errors = $session->getErrors(); } else { if (empty($errors)) { Audit::add('admin', 'create', $session->id, null, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_Operation_Session')); $this->redirect(array('/OphTrOperationbooking/admin/viewSessions')); } } } elseif (isset($_GET['sequence_id'])) { $session->sequence_id = $_GET['sequence_id']; } $this->render('/admin/editsession', array('session' => $session, 'errors' => $errors)); }