/**
  * Field add method
  *
  * @return void
  */
 public function add()
 {
     $this->prepareView('fields.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav')));
     $this->view->set('title', $this->view->i18n->__('Structure') . ' ' . $this->view->separator . ' ' . $this->view->i18n->__('Fields') . ' ' . $this->view->separator . ' ' . $this->view->i18n->__('Add'));
     $form = new Form\Field($this->request->getBasePath() . $this->request->getRequestUri(), 'post', 0, $this->project->module('Phire'));
     if ($this->request->isPost()) {
         $form->setFieldValues($this->request->getPost(), array('htmlentities' => array(ENT_QUOTES, 'UTF-8')));
         if ($form->isValid()) {
             $field = new Model\Field();
             $field->save($form);
             $this->view->set('id', $field->id);
             if (null !== $this->request->getPost('update_value') && $this->request->getPost('update_value') == '1') {
                 Response::redirect($this->request->getBasePath() . '/edit/' . $field->id . '?saved=' . time());
             } else {
                 if (null !== $this->request->getQuery('update')) {
                     $this->sendJson(array('redirect' => $this->request->getBasePath() . '/edit/' . $field->id . '?saved=' . time(), 'updated' => ''));
                 } else {
                     Response::redirect($this->request->getBasePath() . '?saved=' . time());
                 }
             }
         } else {
             if (null !== $this->request->getQuery('update')) {
                 $this->sendJson($form->getErrors());
             } else {
                 $this->view->set('form', $form);
                 $this->send();
             }
         }
     } else {
         $this->view->set('form', $form);
         $this->send();
     }
 }