Exemplo n.º 1
0
 public function addInstanceForm()
 {
     if (!tao_helpers_Request::isAjax()) {
         throw new Exception("wrong request mode");
     }
     $clazz = new core_kernel_classes_Class(CLASS_TAO_USER);
     $formContainer = new tao_actions_form_CreateInstance(array($clazz), array());
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $properties = $myForm->getValues();
             $instance = $this->createInstance(array($clazz), $properties);
             $this->setData('message', __($instance->getLabel() . ' created'));
             //$this->setData('reload', true);
             $this->setData('selectTreeNode', $instance->getUri());
         }
     }
     $this->setData('formTitle', __('Create instance of ') . $clazz->getLabel());
     $this->setData('myForm', $myForm->render());
     $this->setView('form.tpl', 'tao');
 }
Exemplo n.º 2
0
 /**
  * Add an instance of the selected class
  * @return void
  */
 public function addInstanceForm()
 {
     if (!tao_helpers_Request::isAjax()) {
         throw new Exception("wrong request mode");
     }
     $clazz = $this->getCurrentClass();
     $formContainer = new tao_actions_form_CreateInstance(array($clazz), array());
     $myForm = $formContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $properties = $myForm->getValues();
             $instance = $this->createInstance(array($clazz), $properties);
             $this->setData('message', __($instance->getLabel() . ' created'));
             $this->setData('reload', true);
             //return $this->redirect(_url('editInstance', null, null, array('uri' => $instance)));
         }
     }
     $this->setData('formTitle', __('Create instance of ') . $clazz->getLabel());
     $this->setData('myForm', $myForm->render());
     $this->setView('form.tpl', 'tao');
 }