![](/img/trans.png)
[英]Symfony2 - How to stop Form->handleRequest from nulling fields that don't exist in post data
[英]How to handleRequest from html form in Symfony?
我有簡單的 html 表格和 controller 來處理它。 請注意,我沒有在 html.twig 中使用 Symfony 的 forms,例如{{form_start(form)}}...
所以我想從 Controller 中的簡單 html forms 處理。
我的請求正文包含在下面
+request: Symfony\Component\HttpFoundation\ParameterBag {#10
#parameters: array:2 [
"name" => "name"
"amount" => "name"
]
}
在 Controller.php 我有 $form
$defaultData = ['message' => 'Type your message here'];
$form = $this->createFormBuilder($defaultData)
->add('name')
->add('amount')
->getForm();
//here I can't handle the request;
$form->handleRequest($request);
// only 'message' is contain
dd($form->getData());
如何在沒有數據的情況下使用表單 Class從文檔中我嘗試在不使用$data = $request->request->get('data')
情況下處理來自 html 表單的請求
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.