Tuesday, 15 March 2011

api - FOSRestBundle post many to one relation -


I would like to know that the entity has several other connections in the FIST bundle, how can I properly post the data .

The user unit has Locale_ID:

  / ** * @ORM \ manyToOne (targetEntity = "Locale") * @ORM \ JoinColumn (name = " Locale_id ", referenced columnname =" id ") * / personal $ locale;  

I was expecting something like this:

  {"user": {"firstName": "John", "emailAddress" "" "" "," Last name ":" do "," gender ":" 1 "," locale ": {" id ":" 1 "}}}  
<">" code ": 400," message ":" Validation failed "," Errors ": {" Children "will work, but it does not throws verification and symphony: : {"First name" ["," last name ": []," email address ": []," gender ": []," locale ": {" Errors ": [" This value is not valid. " ]}}}}

As you can see, the locale is still wrong.

Does anybody know how can I post it properly?

EDIT

looks like how:

   ("' & gt; true] , 'Option' => ('0';); - 'gt; (' sex ',' likes', ['labels' = & gt;' word.sex ',' options' => ['0' = & Gt; 'mall', '1' = & gt; word 'female'], 'required' => true, 'empty_mana' = & gt; 'word selection', 'empty_data' = & Gt; NU Ll]) - & gt; Add ('locale', 'unit', ['label' = & gt; 'Word.locale', 'required' => false, 'property' = & Gt; 'code', 'square' = & gt; 'softwares' Air bundle: locale, 'query_builder' => function (entity repository $ er) {return $ er-> createQueryBuilder ('L') - & gt; orderbike ('l.code', 'ASC') ;}, 'Placeholder' = & gt; 'word selection', 'empty_data' => gt; zero]);} public function set default options (optionsResolverInterface $ resolver) {$ resolver- & gt; setDefaults (['translation_domain' = & Gt; 'Normal', 'data_clash' = & gt; 'Software' bundle \ unit \ user ',' atric '= & gt; ['Analoget' = & gt; 'Analogite'], 'CSRF_prottage' = & gt; wrong]); } Public Function getName () {Return 'User'; }}  

Edit

and Controller:

  Public function postAction (request $ request ) {$ Form = $ this- & gt; CreateForm (new user type), new user ()); $ Form & gt; HandleRequest ($ request); If ($ form-> isValid () (die ('Are you valid or not ??');} $ $ return-> (see $ form, 400);}   

Edit:

  {"user": {"firstName": "John", "emailAddress": "somewhere@somehow.com", "lastName": "Do", "gender": "1", "locale": 1}}}  

No comments:

Post a Comment