-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[twig] form_enctype deprecated #12333
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
Comments
You're right - it says I prefer writing my form tag myself (obviously, inline with the best practice). So, should we: A) Not deprecate/remove |
What was the reasoning on deprecating form_enctype? Is there a PR that discusses why? I have changed the way I have done some things to follow best practices because they just make sense. However, I will most likely continue to use form_start because I do not agree with "it takes away clarity". What can be more clear than form_start. It does exactly what it sounds like, and the benefits are you do not have to remember/worry about if there is a file upload or not, not worry about names, etc. |
The rationale was that writing your form tag isn't hard. Of course form_start isn't hard either... unless you need to add a class or some other attribute (well, not hard, but ugly and non-obvious - i.e. You need to read the docs to know how). On the other hand, enctype is more manual, and there's also a little weirdness since your form object is programmed to respond to a certain HTTP method, which you then repeat in the template. So, I prefer to write my form tag, since adding an attribute is so simple. That being said, I'm not totally happy with the form flow - it's a bit ambiguous because we have 2 ways of doing things (setting method +action in form and using form_start or doing things manually). Anyways, I appreciate the conversation :). Cheers! |
I think this is a matter of opinions and not a issue, personally I like to use form() or form_start / form_row / form_rest / form_end to render my forms I dont like to render my forms manually. |
Well the issue is is that there is conflicting information between the docs (form_enctype deprecated use form_start) and the best practices(don't use form_start use form_enctype). I personally am going to stick with form_start because I don't want to worry about rendering manually either. Ryan thanks for the info. I see where you coming from, but you have same issue with form widgets. Always regarding option a or b I am not sure the better option since I am going to stick with form_start but interested to hear others thoughts. |
You're right about having the same issue with form_widget, but that's unavoidable - and form_widget gives you a lot of functionality - whereas form_start only gives you the enctype (and the action+method if you like setting those in your form, which I don't like personally). @javiereguiluz I'd love to know your thoughts on this :) |
@weaverryan to be honest, I'm 50-50 on this issue:
|
In my opinion, the best practices are wrong here and should be fixed.
I personally don't recommend to render form tags manually. This will only lead to unnecessary bugs.
This problem applies to all form elements and is a separate issue. I agree that this should be fixed. |
@webmozart After thinking about this awhile, I agree with you. You have listed a lot of pro's for doing things this way, and I think the cons are less (difficult/ugly to add an And about my cons, I think there is some room to make them better. For example, I don't love the syntax for configuring the action and method. I would rather be able to do: $form = $this->createForm(new FooType());
$form->setAction($this->generateUrl('foo_new'));
$form->setMethod('POST'); That's kind of like Anyways, I've opened an issue about the best practice: symfony/symfony-docs#4402. Thanks! |
@weaverryan I love the idea of having a setAction and a setMethod methods. right now it is extremely ugly setting it in the array. I don't see why it wouldn't work BC as the options method would still be valid. I always set method and action regardless if I am submitting back to the same endpoint. Obviously that is way out of scope of this issue but I don't think it should be forgotten about. Maybe could open an issue tagged with dx? |
Cool! See #12368. I think |
Yeah I suppose your right, as now you are adding dependency. But Ill definitely add it to my base class |
Replaced by symfony/symfony-docs#4402. |
Not sure if this is the right place to comment on your best practices book, if it isn't please inform me on where to put this comment.
I just read through your best practices book, and in it it mentions
""BEST PRACTICE
Don't use the form() or form_start() functions to render the starting and ending
form tags."
And right in the example above it it uses the form_enctype function, which was deprecated in 2.3 and to be removed in 3.0. The docs say we should use form_start instead
The text was updated successfully, but these errors were encountered: