-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Hi guys,
I'm new to using liform-react but I think it's really fantastic! Unfortunately I can not quite understand how to use the processSubmitErrors function I saw in the example in: https://github.com/Limenius/symfony-react-sandbox. As in the example in case the form is not valid, I return the normalized form and pass it to the function but it does not seem to work. Can someone give me some advice?
Thank you.
$serializer = $this->get('serializer');$em = $this->getDoctrine()->getManager();
$label = new Label();
$form = $this->createForm(LabelType::class, $label);
$data = json_decode($request->getContent(), true);
$form->submit($data);
if($form->isValid() && $form->isSubmitted()) {
$em->persist($label);
$em->flush();
return new JsonResponse(array(
'success' => 'Success!!'
));
}
return new JsonResponse($serializer->normalize($form), 400);
return fetch(baseUrl + "api/label/new", {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(label)
}).then( (response) => {
return response.json();
}).then( (data) => {
processSubmitErrors(data);
dispatch(labelsActions.addLabel(label));
});
Metadata
Metadata
Assignees
Labels
No labels