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

HTML5 browser_validations is false by default not true #1216

Closed
aliaksandrb opened this issue Mar 6, 2015 · 3 comments
Closed

HTML5 browser_validations is false by default not true #1216

aliaksandrb opened this issue Mar 6, 2015 · 3 comments

Comments

@aliaksandrb
Copy link

Hi guys!
First of all thanks for the great gem, it makes development process much easier and faster! 👍

By the way, I've faced strange behavior recently and believe that it is a bug. Let me describe it.

I am using simple_form for foundation via rails generate simple_form:install --foundation.

The documentation says :

If you want to have all other HTML 5 features, such as the new field types, you can disable only the browser validation:
SimpleForm.browser_validations = false # default is true

But if we check it, than we see that SimpleForm.browser_validations = false by default, not true

I found only two places where it could be changed:
initializers/simple_form.rb

config.browser_validations = false

and
lib/simple_form.rb

mattr_accessor :browser_validations
@@browser_validations = true

And I suspect the problem is in the generator for simple_forinstallation
install_generator.rb

It generates both files simple_form.rb and simple_form_foundation.rb (or bootstrap) even we chose only for Foundation.
Then Rails is loading initializers in alphabetical order, so browser_validations became false because of initializers/simple_form.rb and then this option used it foundation initializer because there is not override there.

So few questions:

  • should the browser_validations be set to true in initializers/simple_form.rb (and both foundation and bootstrap initializers) ? - this is according to the README. Or update the README appropriately.
  • what is the reason for generating initializers/simple_form.rb when we installing simple_form for Foundation/Bootstrap? Maybe it's fine to not doing it and duplicate common options in each initializer if any?
  • Want I send an PR ? 😊
@jedschneider
Copy link
Contributor

@aliaksandrb does this seem like a similar issue? #1178 I have a PR I'm working on, but can't seem to get support for a valid test case.

@aliaksandrb
Copy link
Author

@jedschneider I'm not sure if it's related but looking for your test here: #1178 (comment) I suspect that problem could be in the small typo:

the wrapper created with

b.use :label_text, required: true

but test overrides and looking for input, not label:

with_concat_form_for(@user) do |f|
  concat f.input :name, required: false
end
assert_no_select 'input[type=text][required]'

Correct me if I'm wrong, never wrote tests for simple_form yet :)

@feliperenan
Copy link
Collaborator

It's been a long time since that this issue was open and I don't if it is issue yet, so I'm closing it. Feel free to reopen it if it's necessary.

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

3 participants