/**
  * Role add method
  *
  * @return void
  */
 public function add()
 {
     $this->prepareView('roles.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav')));
     $this->view->set('title', $this->view->i18n->__('User Roles') . ' ' . $this->view->separator . ' ' . $this->view->i18n->__('Add'));
     $form = new Form\UserRole($this->request->getBasePath() . $this->request->getRequestUri(), 'post', 0, $this->project->module('Phire'));
     // If form is submitted
     if ($this->request->isPost()) {
         $form->setFieldValues($this->request->getPost(), array('htmlentities' => array(ENT_QUOTES, 'UTF-8')));
         // If form is valid, save new role
         if ($form->isValid()) {
             $role = new Model\UserRole();
             $role->save($form);
             $this->view->set('id', $role->id);
             if (null !== $this->request->getPost('update_value') && $this->request->getPost('update_value') == '1') {
                 Response::redirect($this->request->getBasePath() . '/edit/' . $role->id . '?saved=' . time());
             } else {
                 if (null !== $this->request->getQuery('update')) {
                     $this->sendJson(array('redirect' => $this->request->getBasePath() . '/edit/' . $role->id . '?saved=' . time(), 'updated' => '', 'form' => 'user-role-form'));
                 } else {
                     Response::redirect($this->request->getBasePath() . '?saved=' . time());
                 }
             }
             // Else, re-render the form with errors
         } else {
             if (null !== $this->request->getQuery('update')) {
                 $this->sendJson($form->getErrors());
             } else {
                 $this->view->set('form', $form);
                 $this->send();
             }
         }
         // Else, render the form
     } else {
         $this->view->set('form', $form);
         $this->send();
     }
 }