How to get posted values of form

Other symfony projects

How to get posted values of form

Postby 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?

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

Re: How to get posted values of form

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

Symfony renders form field names using this taplate:
formName[fieldname]
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:
http://www.symfonyreference.com
User avatar
woolfas
Member
 
Posts: 61
Joined: Mon Nov 08, 2010 2:31 pm
Location: Lithuania

Re: How to get posted values of form

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

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


Return to Other

Who is online

Users browsing this forum: No registered users and 2 guests