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' => 'utenti', 'action' => 'index')); } $form = new Registro("registro"); $form->setInputFilter(new RegistroValidator()); // Obtenemos los datos desde el Formulario con POST data: $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form->setData($data); // Validando el form if (!$form->isValid()) { $id = $data['id']; $imagen = $this->getUtentiDao()->tuttiPerId($id)->getImmagine(); $modelView = new ViewModel(array('title' => 'Aggiorno', 'form' => $form, 'volver' => 'Indietro', 'titulo' => 'Modifica utente', 'imagen' => $imagen)); $modelView->setTemplate('admin/utenti/crear'); return $modelView; } $bcrypt = new Bcrypt(array('salt' => 'aleatorio_salt_pruebas_victor', 'cost' => 5)); $securePass = $bcrypt->create($data['password']); $segura = array('password' => $securePass); $segura2 = array('confirmarPassword' => $securePass); $dataForms = $form->getData(); $datoimagen = $dataForms['immagine']['tmp_name']; $datospimagen = array('immagine' => $datoimagen); $dati = array_replace($dataForms, $datospimagen, $segura, $segura2); $producto = new Utenti(); $producto->exchangeArray($dati); $this->getUtentiDao()->salvare($producto); return $this->redirect()->toRoute('admin', array('controller' => 'utenti', 'action' => 'index')); }