Skip to content
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

Missing float field HTML5 validation #3289

Closed
cimbalo opened this issue Jul 6, 2020 · 0 comments · Fixed by #3378
Closed

Missing float field HTML5 validation #3289

cimbalo opened this issue Jul 6, 2020 · 0 comments · Fixed by #3378
Milestone

Comments

@cimbalo
Copy link

cimbalo commented Jul 6, 2020

Float field are rendered as text input and have no HTML5 validation on submit.
This permit to submit non numerical values for a float field.

I think the following definition are missing in lib/rails_admin/config/fields/types/float.rb

register_instance_option :view_helper do
  :number_field
end

register_instance_option :html_attributes do
  {
    required: required?,
    step: "any",
  }
end

This will change the rendered field from:
<input class="form-control" type="text" [...]>
to:
<input class="form-control" step="any" type="number" [...]>

If this issue is confirmed I can make a PR for it.

Edit: added 'required' attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants