예제 #1
0
 public function nuevoAction()
 {
     $request = $this->getRequest();
     //Intanciamos nuestro formulario
     $form = new \Bancos\Form\ConceptoForm();
     if ($request->isPost()) {
         //Si hicieron POST
         //Instanciamos nuestro filtro
         $filter = new \Bancos\Filter\ConceptoFilter();
         //Le ponemos nuestro filtro a nuesto fromulario
         $form->setInputFilter($filter->getInputFilter());
         //Le ponemos los datos a nuestro formulario
         $form->setData($request->getPost());
         //Validamos nuestro formulario
         if ($form->isValid()) {
             //Instanciamos un nuevo objeto de nuestro objeto lugar
             $entity = new \Conceptobanco();
             //Recorremos nuestro formulario y seteamos los valores a nuestro objeto Lugar
             foreach ($form->getData() as $key => $value) {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
             //Guardamos en nuestra base de datos
             $entity->save();
             //Agregamos un mensaje
             $this->flashMessenger()->addMessage('Concepto guardado exitosamente!');
             //Redireccionamos a nuestro list
             return $this->redirect()->toRoute('bancos-concepto');
         } else {
             var_dump($form->getMessages());
         }
     }
     return new ViewModel(array('form' => $form));
 }
예제 #2
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aConceptobanco !== null) {
             if ($this->aConceptobanco->isModified() || $this->aConceptobanco->isNew()) {
                 $affectedRows += $this->aConceptobanco->save($con);
             }
             $this->setConceptobanco($this->aConceptobanco);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->referenciaabonosScheduledForDeletion !== null) {
             if (!$this->referenciaabonosScheduledForDeletion->isEmpty()) {
                 ReferenciaabonoQuery::create()->filterByPrimaryKeys($this->referenciaabonosScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->referenciaabonosScheduledForDeletion = null;
             }
         }
         if ($this->collReferenciaabonos !== null) {
             foreach ($this->collReferenciaabonos as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }