14.
PUT is for Updating
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
7 Comments
Hello
I want to validate data and write in the controller:
but $form->isValid() don't work
UserController.php
how could I validate data in this case?
Hi Nina,
What is your question? I don't see any text except "Hello" ;)
Cheers!
And now )
Hey Nina,
Do you get any errors when trying to validate ?
Also you are injecting an User object to your controller action, and you never use it, you should only rely on the ID
BTW, next course is all about errors, you may want to hold a little bit before adding validations :)
Yes, thanks I see the next course.
And now I use :
$validator = $this->get('validator');
$errors = $validator->validate($user);
if(!$errors){
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
}
$data = $this->container->get('jms_serializer')->serialize($errors, 'json');
return new Response($data);
and I got JSON response with error
this what I want to give
Thanks again for your lessons and help
Excellent! Feel free to contact us if you have more questions about our tutorials :)
Hi. Not sure if this is happening to anyone else but there is no audio on this video? Thanks!
*Edit: Sorry it's my computer, ignore.
"Houston: no signs of life"
Start the conversation!