Apr 152012
 

In symfony2, if you want to get value from request, you have many ways:

forst, bind request to form, then you can use the entity, official document has details.

If you are using formtype, there is another two ways to get value,

first:

$postData = $request->request->get('slackiss_bundle_qingbundle_registertype');
$name_value = $postData['email'];

second:

$email = = $form["email"]->getData();

or

$defaultData = array('message' => 'Type your message here');
$form = $this->createFormBuilder($defaultData)
->add('name', 'text')
->add('email', 'email')
->add('message', 'textarea')
->getForm();

if ($request->getMethod() == 'POST') {
$form->bindRequest($request);

// data is an array with "name", "email", and "message" keys
$data = $form->getData();
}

If you do not use formtype, I mean, you are not using {{form_widget}}, you can get values:


echo $request->request->get('email');

About $request, the code is like:

public function doAction(Request $request)
{
}

or

$request = $this->getRequest();