Comments (1)
I agree that abide validation would be great, I don't think the framework should automatically add the data-abide attribute to the form based on specific attributes on controls however.
If form_for
had an option to enable abide validation which subsequently added the error tags to controls then that would work great in all scenarios. The main problem here would be how to get a generalised error message depending on the validation that failed.
I propose something like the following should be flexible enough for most cases:
= form_for(@user, abide: true) do |f|
= f.text_field :username, required: true, pattern: '[a-zA-Z]+', error: 'Please enter your username'
= f.password_field :password, required: true, error: 'Password is required'
Which would generate the following html:
<form class="new_user" action="/users/new" data-abide accept-charset="UTF-8" method="post">
<div class="user-username-field">
<label for="user_username">Username <small>required</small>
<input type="text" name="user[username]" id="user_email" required pattern="[a-zA-Z]+">
</label>
<small class="error">Please enter your username</error>
</div>
<div class="user-password-field">
<label>Password <small>required</small>
<input type="password" name="user[password]" id="user_password" required>
</label>
<small class="error">Password is required</small>
</div>
</form>
It would be even better if the code generating the fields could automatically add pattern and required attributes based on rails validations but that would probably be a bit more difficult!
from foundation_rails_helper.
Related Issues (20)
- Add ability to add prefix and postfix HOT 8
- Radio Button Helper Renders Value in Label HOT 2
- Needs a version bump. HOT 14
- Migrate TravisCI to container-based infrastructure HOT 1
- Remove Ruby 1.9.3 from supported Rubies HOT 13
- Support for Foundation 6 HOT 4
- fggh HOT 2
- Support rails 5 HOT 1
- alias_method_chain is deprecated HOT 6
- Failing spec with Rails 5 HOT 3
- Release a new gem version for Rails 5 support HOT 2
- Foundation 6 - Form input "hint" is now "help text" HOT 1
- Foundation 6 - Change default button class HOT 2
- Release 3.0.0 HOT 7
- Make error_for method in form_builder public HOT 1
- Overriding the field_error_proc HOT 2
- display_flash_messages return nil on redirection HOT 4
- Newest changes that include update to support rails 6 in gemspec not in rubygem.org HOT 2
- Can we release a new version of the gem so we can upgrade our rails to >= 6.1 HOT 1
- Publish v4.0.0 code on GitHub HOT 2
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 foundation_rails_helper.