public function actionAdd() { $model = new Structure; if(isset($_POST['Structure'])) { $model->attributes = $_POST['Structure']; if($model->save()){ $this->redirect(array('list')); } } $this->render('add',array('model'=>$model)); }
public function executeUpdateStructure(sfWebRequest $request) { $structureName = $request->getParameter('structure_name'); if (strlen($structureName)) { $structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne(); // ----------------------------------------------------------------------------------------------------------- // KYXAR 0008 - 08/07/2011 // On vérifie qu'il y a bien une structure en BD if ($structure === false) { $address = Doctrine::getTable('address')->createQuery('a')->fetchOne(); if ($address === false) { $addr = new Address(); $addr->setAddress_city_id(40147); $addr->save(); $address = Doctrine::getTable('address')->createQuery('a')->fetchOne(); } $addr_id = $address->getId(); $struct = new Structure(); $struct->setName($structureName); $struct->setLogo_path('logo.png'); $struct->setAddress_id($addr_id); $struct->save(); $structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne(); } // FIN KYXAR // ----------------------------------------------------------------------------------------------------------- $structure->setName($structureName); $structure->save(); $this->getUser()->setFlash('notice', 'The structure has been created.'); $this->redirect('firstBoot/stepThree'); } else { $this->getUser()->setFlash('error', 'The structure name cannot be empty.', false); $this->setTemplate('stepTwo'); } }