function step3() { Monc::import('monc.form.FormForm'); $model = new FormForm(); if ($this->isPost()) { $model->setAttributes($this->post('FormForm')); if ($model->save()) { $this->user->setState('form', $model->getAttributes()); $this->redirect(curl('step4')); } } else { if ($data = $this->user->getState('form')) { $model->setAttributes($data); } } $this->render('form', array('model' => $model)); }
public function editAction() { // web page title $this->view->title = "Edition de formulaire"; // Tests if the user has permissions if ($this->view->aclIsAllowed($this->_name, 'manage', true)) { // set variables needed for the process $formID = $this->_getParam('formID'); $returnAction = $this->_getParam('return'); $pageID = $this->_getParam('pageID'); $blockID = $this->_getParam('blockID'); $baseDir = $this->view->baseUrl(); if (empty($formID) && !empty($blockID)) { $formID = Cible_FunctionsBlocks::getBlockParameter($blockID, '1'); } // Define the url where to return if ($returnAction) { $returnUrl = "/form/index/{$returnAction}"; } elseif ($pageID) { $returnUrl = "/page/index/index/ID/{$pageID}"; } else { $returnUrl = "/form/index/list/"; } //Add specific js file $this->view->headScript()->appendFile($this->view->locateFile('headerFormActions.js')); $this->view->headScript()->appendFile($this->view->locateFile('tiny_mce/tiny_mce.js')); $oNotifications = new FormNotificationObject(); $recipients = $oNotifications->getAll(null, true, $formID); // Get data for the current form $oForm = new FormObject(); $data = $oForm->populate($formID, $this->getCurrentEditLanguage()); //Generate the form for the back button $formBack = new FormBackButton(array('baseDir' => $baseDir, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'disableAction' => false)); $formBack->removeElement('submitSave'); $formBack->getElement('cancel')->setDecorators(array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'li')), array(array('row' => 'HtmlTag'), array('tag' => 'ul', 'openOnly' => true, 'class' => 'actions-buttons'))))->setOrder(1); $this->view->formBack = $formBack; //Generate the form $form = new FormForm(array('baseDir' => $baseDir, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'formID' => $formID, 'disableAction' => true, 'recipients' => $recipients)); $this->view->form = $form; //Add question type data $oQuestion = new FormQuestionTypeObject(); $questionData = $oQuestion->getAll($this->getCurrentEditLanguage()); $this->view->questionType = $questionData; // action: If not post action (send modification) if (!$this->_request->isPost()) { //Populate the for with data from db $form->populate($data); } else { // Get data sent $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $languages = Cible_FunctionsGeneral::getAllLanguage(); var_dump($languages); exit; // and save value in db $oForm->save($formID, $formData, $this->getCurrentEditLanguage()); $oForm->save($formID, $formData, $this->getCurrentEditLanguage()); $this->_redirect($returnUrl); } } } }