Commit Graph

23 Commits

Author SHA1 Message Date
Felipe Renan 71a95b95fa Fix tests that are broken after nokogiri 1.8.4
I'm not sure why it have happened, but after nokogiri 1.8.4 these tests
started to break.

I'm updating the match syntax to let it green again. See more about it
in the link below:

https://edgeguides.rubyonrails.org/4_2_release_notes.html#assert-select
2018-08-06 11:46:39 -03:00
Petteri Räty 1970d8b17e Improve disabled option to input_field
Allows individual options to be disabled instead of just the whole
select.

Fixes #1365.
2018-05-13 17:05:30 +03:00
Felipe Renan fad039320e Allow validation classes on input_field
This PR is similar to this one https://github.com/plataformatec/simple_form/pull/1552.
It allows validation classes on `input_field`.

To get this work I added two configs for the Simple Form:
`input_field_error_class` and `input_field_valid_class`. Once the user
adds a class for these configs, the configured classes will be rendered
according to the form validation.

- Setup the `input_field` classes.
```ruby
SimpleForm.setup do |config|
  config.input_field_valid_class = 'is-valid'
  config.input_field_error_class = 'is-invalid'
end
```

- Build the form.
```erb
<%= simple_form_for @product do |f| %>
  <%= f.input_field :name %>

  <div class="form-actions">
    <%= f.button :submit %>
  </div>
<% end %>
```
- When the validation happening, the input will be rendered with the
validation classes.
```HTML
<-- Valid example -->
<input class=" is-valid string required" type="text" value="PS4" name="product[name]" id="product_name">

<-- Invalid example -->
<input class=" is-invalid string required" type="text" value="" name="product[name]" id="product_name">
```
2018-04-04 19:49:24 -03:00
Andres Ehrenpreis 928adab801 Code cleanup 2018-01-08 10:29:03 +02:00
Dillon Welch cac943e891 Add frozen_string_literal in all .rb files
I noticed these files all had strings such as "", "  ", "_" that were
allocated each time some common methods were called, over 1000x on a
page in my app. This comment freezes all of these strings such that
they're only allocated once, saving many KB of memory allocation.
2017-11-27 17:06:18 -08:00
Lucas Mazza 48cab46ca4 Merge pull request #1420 from sethveale/master
Added Minlength validation with tests a la Maxlength
2016-11-16 09:58:36 -02:00
Jon Evans a14a2028cc Fix typo 2016-10-05 15:06:43 -06:00
Seth Veale bf2cca100c Added failing minlength tests to string and text input tests, and to ValidatingUser 2016-08-22 14:36:45 +12:00
Seth Veale ae526b30c7 Added a minlength validation on first attempt? Wooo - wish I could put bangs in commit messages *bang* 2016-08-22 10:32:54 +12:00
Lucas Mazza e62018afa8
Do not emit `prompt` as an HTML attribute when using `input_field`. 2016-08-09 11:34:02 -03:00
Carlos Antonio da Silva 958b823aaf Simplify input field tests with a small helper to generate the form + field 2015-03-25 08:59:00 -03:00
Carlos Antonio da Silva 96cf04fb21 Remove extra self 2015-03-25 08:17:42 -03:00
Rafael Mendonça França 6c28bf4833 Do not remove HTML attributes if components are not present
Closes #1096
2014-11-19 19:20:17 -02:00
Rafael Mendonça França 12e6d89b77 Remove all warnings of invalid CSS selector 2014-09-08 17:19:40 -03:00
John Voloski 3bff1fa5a1 improve form_builder's tests description and remove 'should' 2014-05-14 14:18:43 -03:00
Erich Kist 987083511b Merge pull request #941 from plataformatec/ek-doc-boolean-style
Add to REAME some doc to boolean_style
2013-12-10 12:39:45 -08:00
Lucas Mazza eb5b63cd46 Don't render the `boolean_style` as an HTML attribute on `input_field`. 2013-12-10 14:29:37 -02:00
Vasiliy Ermolovich 10cc21607f input_field uses the same wrapper as input but only with attribute components
closes #938 #823
2013-11-29 21:36:16 +03:00
Vasiliy Ermolovich c2c7d95c56 add html5 component support to input_field
closes #802
2013-05-17 00:04:08 +03:00
Vasiliy Ermolovich b0e8d1f70c add components that don't generate tags for input_field
closes #632

Conflicts:

	lib/simple_form/form_builder.rb

Conflicts:

	lib/simple_form/form_builder.rb
2013-01-29 23:19:19 +03:00
Renato Mascarenhas 34312c9fbc Use 1.9 hash style on code and docs. 2013-01-28 19:02:59 -02:00
Rafael Mendonça França f4a1ac6f83 FormBuilder methods should not modify the options hash
Closes #463
2012-02-21 01:42:06 -02:00
José Valim 3ee59b5d0d Break form builder test into smaller files. 2011-09-08 16:04:36 +02:00