Ver Mensaje Individual
  #9 (permalink)  
Antiguo 30/06/2014, 13:30
pmeninsaxmus16
 
Fecha de Ingreso: noviembre-2013
Mensajes: 83
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: Enviando formularios con varios botones Symfony2

Controller
Código PHP:
 public function newAction()
    {
        
$entity = new Users();
        
$form   $this->createForm(new UsersType(), $entity);

        return array(
            
'entity' => $entity,
            
'form'   => $form->createView()
        );
    }


    
/**
    * Creates a form to create a Contact entity.
    * @param Contact $entity The entity
    * @return \Symfony\Component\Form\Form The form
    */
   
private function createCreateForm(Contact $entity)
    {        
        
$form $this->createForm(new ContactType($this->getDoctrine()->getManager()), $entity, array(
            
'action' => $this->generateUrl('admission_contact_applicant_save'),
            
'method' => 'POST', ));
         
$form->add('saveAndNew''submit', array('label' => 'saveAndNew''attr'=> array('id'=>'new''class'=>'btn-primary')));
         
$form->add('save''submit',array('label' => 'save''attr'=> array('id'=>'finish')));
       
//)); 
        
return $form;
    } 
En el save
Código PHP:
if ($form->get('saveAndNew')->isClicked()) {
        return 
$this->redirect($this->generateUrl('ABCAdmission_applicant_resumen', array('id'=>$id)));
    } 
luego en el else el resto, pero no funciona, porque nose