public function guardarAction() { $this->getConfig(); $menu = $this->config['parametros']['menu1']; $this->layout()->menu = $menu; if (!$this->request->isPost()) { return $this->redirect()->toRoute('admin', array('controller' => 'interattivo', 'action' => 'index')); } $xposition = rand(2, 1000); $yposition = rand(3, 850); $zposition = rand(1, 100); //print_r($xposition.'x'.$yposition.'x'.$zposition);die; $patron = 'Y-m-d H:i'; $fecha = new DateTime(); $form = new Interact("interact"); $form->get('nome')->setValue('default'); $form->get('posterlab')->setValueOptions($this->getInterattivoDao()->obtenerPosterlabsSelect()); //print_r($this->llenarListaTipo());die; $form->get('tipo')->setValueOptions($this->llenarListaTipo()); $form->get('data')->setValue($fecha->format($patron)); $form->get('sessione')->setValue(0); $form->get('color')->setValueOptions($this->llenarColor()); $form->get('xyz')->setValue($xposition . 'x' . $yposition . 'x' . $zposition); $form->setInputFilter(new InteractValidator()); $data = $this->getRequest()->getPost()->toArray(); $form->setData($data); // Validando el form if (!$form->isValid()) { $modelView = new ViewModel(array('title' => 'Aggiorno', 'form' => $form, 'volver' => 'Indietro', 'titulo' => 'Modifica contenuto')); $modelView->setTemplate('admin/interattivo/crear'); return $modelView; } $dataForms = $form->getData(); $dataForms['posterlab_id'] = $dataForms['posterlab']; $producto = new Interattivo(); //print_r($dataForms);die; $producto->exchangeArray($dataForms); $this->getInterattivoDao()->salvare($producto); return $this->redirect()->toRoute('admin', array('controller' => 'interattivo', 'action' => 'index')); }