form type mapped false symfony2

后端 未结 1 1841
不思量自难忘°
不思量自难忘° 2021-01-20 17:09

I have a trouble with a formtype with mapped=false.

In controller, I called the form with:

$form = $this->createForm(new JurisdictionUserNewType(         


        
相关标签:
1条回答
  • 2021-01-20 17:32

    If you set 'mapped' => false on any field, you're saying that that field isn't related to your entity, so you don't get it when you retrieve the entity from the submitted form.

    You can get it anyway as a single field from the form, as:

    $form->handleRequest($request); 
    if ($form->isValid()) { 
        $entity = $form->getData(); 
        $securityUser = $form->get('securityUser')->getData();    
    }
    
    0 讨论(0)
提交回复
热议问题