-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete method is not working #993
Comments
did you debug a bit what is going on? I guess the form is not considered to be valid? what data is in the |
@lsmith77 thanks for replay , I have been debugging this for the last 3 days but with no luck which made think it is a bug . The
|
do you have the BodyListener activated? |
ah yes you do .. can you pastebin the body of the request you send for DELETE with json/xml? |
@lsmith77 Yes the body listener is activated . Here is my curl command I am using
|
but I am right that in the xml/json case the /cc @webmozart |
ping |
@lsmith77 Sorry for taking so long to answer , it is work , sorry again You were write the form layer is not happy in xml/json case , I have edited my curl command to become like this:
as you can see from the response the form method If you think this must not be discussed here , feel free to close the issue , and I will try Stackoverflow to get this right Thanks for being patient with me 😄 |
@hyyan Why do you need to use a form when deleting a resource? |
@tystr Because I am serving the HTML view from same controller which needs a form to perform delete request ? Is that wrong ? |
@hyyan if you used a form with a non-empty root name, it indeed must appear in the request, otherwise it won't be considered as submitted. If you want to avoid this, you could use an empty form name: $form = $this->get('form.factory')->createNamed('', $type, $data); |
@stof Thanks for replay , I have tried this as you suggest , but still the same , working for HTML but it is not for json/xml $this->get('form.factory')->createNamed(
''
, 'form'
, array(
)
, array(
'action' => $this->generateUrl('tasks_delete', array('id' => $id)),
'method' => 'DELETE' ,
'csrf_protection' => false,
'allow_extra_fields' => true,
)
)
->add('submit', 'submit', array('label' => 'Delete')) |
Hello, I'm running on exactly the same issue here. When using a browser and HTML, the form fakes the DELETE method and sends a POST request with an hidden input, thus validating the form. When using Postman or curl with the real DELETE method, the request body is empty, preventing the form from being submitted. Though I guess Friends of Symfony will find a turnaround about this (I hope so!), I'm wondering if this issue shouldn't be related to the Symfony Form Component itself? |
@hyyan @bpolaszek could you create a fork of the |
@hyyan @bpolaszek You need to make sure that the |
Hey , thanks for the great work guys , it is impressive
I am trying to build a simple task api just to learn , and everything is working great , except for the delete request , the form validation is passing in html but it is not in json or xml and I keep getting the 400 code error (Bad Request)
I didn't post this in Stack Overflow cause I think it is a bug ,
Note : I am using the master brunch
Here's my bundle config ;
And here's my controller methods :
And finally the route:
Any idea will be helpful , thanks in advance
The text was updated successfully, but these errors were encountered: