Пример #1
0
 public function action_add()
 {
     $this->template->title = 'Add Role';
     //print_r($data['roles']);
     $data = array();
     if ($_POST) {
         $role = new Model_Role();
         $post = $role->validate_create($_POST);
         if ($post->check()) {
             $values = $post->as_array();
             unset($post);
             $role->name = $values['name'];
             $role->description = $values['description'];
             $role->save();
             Request::instance()->redirect('role/index');
         } else {
             #Get errors for display in view
             $data['errors'] = $post->errors('racl/role/add', TRUE);
             #Repopulate $_POST data
             $_POST = $post->as_array();
         }
     }
     //
     $this->template->content = View::factory('racl/role/add', $data);
 }