/** * 修改一个每日任务 */ public function actionUpdate() { $cronForm = new CronForm('update'); if (Yii::app()->request->getIsPostRequest()) { $post = Yii::app()->request->getPost('CronForm'); $cronForm->setAttributes($post, false); if ($cronForm->validate()) { $minuteTime = date('H:i'); if ($post['runtime'] < $minuteTime) { $post['last_run_date'] = date('Y-m-d'); } else { $post['last_run_date'] = '0000-00-00'; } $id = $post['id']; unset($post['id']); $post['update_time'] = time(); if (CronModel::instance()->update($id, $post)) { $this->redirect(array('/cron')); } } } else { $id = Yii::app()->request->getQuery('id'); $cron = CronModel::instance()->getById($id); $cronForm->setAttributes($cron, false); $this->setTitle('修改每日任务'); } $this->render('update', array('cronForm' => $cronForm)); }