用戶sumbits這是構建使用symfony的2框架與抽象類型的一種形式:獲取AbstractType從請求
<?php
$form = $this->createForm(new MyAbstractType(), new MyEntity());
我接收在動作此篇請求:
public function receiveFormRequestAction(Request $request){
//How do I get the abstract type from the request?
}
我需要能夠僅使用請求中的信息創建表單上使用的AbstractType。
- 這可能嗎?
- 你怎麼做到的?
謝謝。
編輯:
對不起,如果我不夠清楚。在「recieveFormRequestAction」方法中,我不知道我將得到什麼抽象類型,所以我不能直接將表單綁定到MyAbstractType。
理論上,此操作可以接收任何AbastractType並將其綁定。