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

Generate HTML5 date/time inputs by default #1739

Open
marcelolx opened this issue May 28, 2021 · 5 comments
Open

Generate HTML5 date/time inputs by default #1739

marcelolx opened this issue May 28, 2021 · 5 comments

Comments

@marcelolx
Copy link

It's a long time ago since HTML5 date/time support was included in simple_form #935 and since then as the docs describe by default they are disabled #1150 because at the time the browsers weren't ready for them, but I think now 8 years after, the browsers are ready as mdn browser compatibility suggests https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#browser_compatibility, what do you think about simple_form turn on the generation of these html5 inputs by default?

This probably would be a breaking change and would require a major release, I suppose

@attenzione
Copy link

attenzione commented Dec 27, 2021

This can be implemented without breaking change, but just add another config option which is false by default:

# initializer
SimpleForm.setup do |config|
  config.default_html5_date_time = false
end

# input helper (simple_form/inputs/date_time_input.rb#L34)
def use_html5_inputs?
  input_options.fetch(:html5, SimpleForm.default_html5_date_time)
end

On a major release this can be switched to true but not necessary

@nashby
Copy link
Collaborator

nashby commented Mar 8, 2022

It looks like a bug to be honest. https://github.com/heartcombo/simple_form/blob/main/lib/simple_form/inputs/date_time_input.rb#L35 it doesn't use html5 config from the wrapper but uses html5 option from the input options. @carlosantoniodasilva do you thing we should make it work the same as e.g NumericInput works?

@rafaelfranca
Copy link
Collaborator

@nashby yes. I think we should match the behavior.

@jtarchie
Copy link

I just experienced this. For anyone reading, you have explicitly set html5: true, as: :date on the field to have it render correctly.

jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
jamezilla added a commit to jamezilla/simple_form that referenced this issue Feb 14, 2024
@jamezilla
Copy link

jamezilla commented Feb 14, 2024

I opened a PR for this. It's not a breaking change, but it's definitely a change to the default behavior since the generated default wrapper is using the html5 component.

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

No branches or pull requests

6 participants