The user sumbits a form that was build using the symfony 2 framework with abstract type:
<?php
$form = $this->createForm(new MyAbstractType(), new MyEntity());
I receive this post request in an action:
public function receiveFormRequestAction(Request $request){
//How do I get the abstract type from the request?
}
I need to be able to create the AbstractType used on the form using only information in the request.
- Is it possible?
- How do you do it?
Thanks.
Edit:
Sorry if i wasn't clear enough. in the method "recieveFormRequestAction" i don't know what abstract type i am going to get, so i cant bind the form directly to MyAbstractType.
This action can, in theory, recieve any AbastractType and bind it.
I ended up doing this:
The method getName() on my forms returned exactly the same name as the Form class name
Now i can get the type using the hash on the parameter keys
Ugly as hell, but i needed a quick solution. Until there is a cleaner one, i'm accepting this.