This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

How to get posted values of form

Other symfony projects

How to get posted values of form

by nikunj.idhasoft » Fri Dec 31, 2010 12:28 pm

Hi Friends,

I am new in symfony. i want to create page of user registration and i want to create user name unique but i don't know how to get posted values of form. i tried $request->getParameter('name'); function but i didn't get any value so please tell me how can i get posted values of form and how can i create user name field unique?

Nikunj Joshi
Junior Member
Posts: 1
Joined: Fri Dec 31, 2010 12:21 pm
Location: Ahmedabad

Re: How to get posted values of form

by woolfas » Mon Jan 03, 2011 9:50 am

Symfony renders form field names using this taplate:
It means that when you post your form, you get the form values in an array under the formName key.
So in order to get you form values you must do something like this:

Code: Select all
$form = new YourForm();
$form_name = $form->getName();
$parameters = $request->getParameter($form_name);

The $parameters variable will hold an array of your form field values.

If you want your username to be unique, thirst thing you must do is to add unique constraint to your databse username field. It will ensure, that there will be no duplicates in your database. And when you get a username from posted form, you must query your database for that user, and if you find one in the database output an error messeage to your registration page.
If you will have trouble of doing that, post your question here.

Symfony Configuration Reference - everything you can't find elsewhere:
User avatar
Posts: 61
Joined: Mon Nov 08, 2010 2:31 pm
Location: Lithuania

Re: How to get posted values of form

by Titusl » Tue Sep 04, 2012 1:16 pm

hey i am also new in symphony but it think you have to search this on help me a can find your answers there easily.
Junior Member
Posts: 1
Joined: Sat Jul 28, 2012 11:25 am
Location: United States