Example #1
0
 public function action_edit()
 {
     $this->redirect_if_not_owner();
     $list_id = $this->request->param('id');
     $list = new Model_List($list_id);
     $this->template->title = 'Edit list';
     $view = View::factory('list/edit');
     $view->list = $list;
     if ($_POST) {
         if (arr::get($_POST, 'name')) {
             $list->name = arr::get($_POST, 'name');
             if (arr::get($_POST, 'expiry') && !preg_match('~^\\d{1,2}/\\d{1,2}/\\d{4}$~', arr::get($_POST, 'expiry'))) {
                 $view->errors = 'Please enter a valid date';
             } else {
                 $list->expiry = arr::get($_POST, 'expiry');
                 $list->save();
                 Message::add('success', __('Successfully updated list.'));
                 Request::current()->redirect('list/mine/' . $list->id);
             }
         } else {
             $view->errors = 'Please enter a circle name';
         }
     }
     $this->template->content = $view;
 }