Get form values in Symfony2 controller , Child does not exist

This is how the source code of input username is :

<input type="text" id="user_username" name="user[username]" >

When I try to get it in the controller I get this error :

Child "username" does not exist

Controllor :

//....... if ($request->getMethod() == 'POST') { $form->handleRequest($request); $i = 0; $username = $form["username"]->getData(); $user= $em->getRepository('UsersBundle:User')->findOneByUsername($username); //....... }

This is th formType

class EleveType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('user', new UserType()) ->add('ecole') ->add('niveauscolaire') ; }



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


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


In my case, I need to use:

$username = $form["user"]["username"]->getViewData();

instead of:

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

Thanks for @Jacob orientation which help me and sorry for my shinny english.


  • Error while creating sales order using JCO with BAPI_SALESORDER_CREATEFROMDAT2
  • Symfony2 / Doctrine queries in loops
  • Issue with the Entity Manager and phpunit in Symfony 2
  • find the children of an object in the database
  • Symfony Save comments on blog with user and blogId
  • Query in multiple embedded Collection Forms
  • How to customize the Data of FullCalenderBundle [Symfony4]
  • symfony 3 Argument 1 passed to [some service]::__construct() must be an instance of [something] inst
  • Netbeans Auto-Complete Not Working For Custom PHP Class
  • what is the difference between getPeeledObjectId() and getObjectId() of Ref Object?
  • Spring Data java.lang.NoSuchMethodError
  • Weird alias [0_ added by doctrine while trying to run with SQL SERVER
  • Symfony2 - Call to undefined method getDoctrine() when overriding FOSUserBundle's ProfileContro
  • In C#, how do I add event handlers to an object based on names?
  • How to create c# console application to cosume the .net webservice [closed]
  • Get MethodInfo for any method with any signature (delegate for any signature)
  • Populate Multiple Forms Symfony2
  • Get form values in Symfony2 controller , Child does not exist
  • Passing command line arguments
  • How to return an array not an object with doctrine findOneBy method in symfony2?
  • Android get Serial Number
  • Write “NOT IN” in Doctrine Query Language
  • Copying rows in a database when rows have children
  • Passing information to server-side function in a Google Docs Add On
  • Why doesnt this Java loop in a thread work?
  • Does CSS support inheritance [duplicate]
  • CSS - Cannot get one spanned style to override another inherited style and align left
  • Xamarin Forms - UWP Fonts
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Symfony2: How to get request parameter
  • log4net write single file for each call to log.info
  • Free memory of cv::Mat loaded using FileStorage API
  • Getting error when using KSoap library to consume .NET web services
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Memory offsets in inline assembly
  • Turn off referential integrity in Derby? is it possible?
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize