Comments (4)
I don't think that forme's Rails support should do something just because Rails form_for
does so.
I do agree that the authenticity_token should be added automatically for forms using POST
, and I'd like to support that on Sinatra as well using rack-csrf.
Personally, I've always thought that Rails' way of trying to fake HTTP verbs that browsers do not support is stupid. I suppose there are Rails applications that rely on it (though none of my Rails apps do), but as it is not strictly necessary, I don't think the method
should be added by default.
The utf8
tag I don't think should be added automatically by default either, as I don't like forcing an encoding on people.
That's not to say that we can't add options that add the method
and utf8
tags automatically, I just don't want it to be the default.
Ideally the underlying implementation for this this would be something transformer-like that is applied to all new Form objects at the end of Form#initialize. The tricky thing about it is making sure the transformer has the ability to access the necessary context containing the authenticity token.
from forme.
Is there a better approach than using _method
? Browsers can only do GET or POST (excluding XMLHttpRequest) and I'm not aware of any other other way to get Rails to handle a PUT or DELETE than the _method
param. I don't think it's great practice either, but I'm just trying to play with the hand I've been dealt.
from forme.
Personally, since browsers only do GET and POST, I don't use other HTTP verbs for actions that I want a browser to execute. For non-browser based applications, I think other HTTP verbs are fine. Considering that forme is a HTML form library designed for browsers, by design it only uses GET and POST.
I do understand playing the hand you've been dealt, and certainly think it would be generally be useful to have a transformer/callback so that all forms created by forme can be modified in a way that suits the app, instead of having to do the same modifications in each call. This even affects my personal usage of forme, since currently I have to add CSRF tags to all POST forms manually.
from forme.
Please give this a shot and let me know if it works for you. I think it should be flexible enough to handle most needs.
from forme.
Related Issues (10)
- haml/slim support HOT 3
- Adding BS3 (Twitter Bootstrap) support HOT 21
- Feature Request: REST APIs route generation HOT 1
- Doc change? HOT 3
- Support for Rack::MethodOverride HOT 2
- Default label for hidden fields HOT 2
- The forme_set plugin remembers columns from another form on the same page HOT 5
- forme_set exlude a column HOT 1
- Form method optional HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forme.