You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a field has a required attribute, the form should get a data-abide attribute and a <small class="error">required</small> should be added below the field. The error message should be able to be edited with a field option.
The text was updated successfully, but these errors were encountered:
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:
<formclass="new_user" action="/users/new" data-abideaccept-charset="UTF-8" method="post"><divclass="user-username-field"><labelfor="user_username">Username <small>required</small><inputtype="text" name="user[username]" id="user_email" requiredpattern="[a-zA-Z]+"></label><smallclass="error">Please enter your username</error></div><divclass="user-password-field"><label>Password <small>required</small><inputtype="password" name="user[password]" id="user_password" required></label><smallclass="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!
Reference: http://foundation.zurb.com/docs/components/abide.html
If a field has a
required
attribute, the form should get adata-abide
attribute and a<small class="error">required</small>
should be added below the field. The error message should be able to be edited with a field option.The text was updated successfully, but these errors were encountered: