Skip to content

Commit

Permalink
Fix tests and code for file and date/time selects.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcreid authored and mattbrictson committed May 29, 2018
1 parent 0d76300 commit 769cf00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/bootstrap_form/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ def initialize(object_name, object, template, options)

define_method(with_method_name) do |name, options = {}, html_options = {}|
form_group_builder(name, options, html_options) do
input_with_error(name) do
content_tag(:div, send(without_method_name, name, options, html_options), class: control_specific_class(method_name))
content_tag(:div, class: control_specific_class(method_name)) do
input_with_error(name) do
send(without_method_name, name, options, html_options)
end
end
end
end
Expand All @@ -65,8 +67,8 @@ def initialize(object_name, object, template, options)
def file_field_with_bootstrap(name, options = {})
options = options.reverse_merge(control_class: "custom-file-input")
form_group_builder(name, options) do
input_with_error(name) do
content_tag(:div, class: "custom-file") do
content_tag(:div, class: "custom-file") do
input_with_error(name) do
placeholder = options.delete(:placeholder) || "Choose file"
placeholder_opts = { class: "custom-file-label" }
placeholder_opts[:for] = options[:id] if options[:id].present?
Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap_fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class BootstrapFieldsTest < ActionView::TestCase
<div class="custom-file">
<input class="custom-file-input is-invalid" id="user_misc" name="user[misc]" type="file" />
<label class="custom-file-label" for="user_misc">Choose file</label>
<div class="invalid-feedback">error for test</div>
</div>
<div class="invalid-feedback">error for test</div>
</div>
</form>
HTML
Expand Down
6 changes: 3 additions & 3 deletions test/bootstrap_selects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
<select class="form-control is-invalid" id="user_misc_3i" name="user[misc(3i)]">
#{options_range(start: 1, stop: 31, selected: 3)}
</select>
<div class="invalid-feedback">error for test</div>
</div>
<div class="invalid-feedback">error for test</div>
</div>
</form>
HTML
Expand Down Expand Up @@ -395,8 +395,8 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
<select class="form-control is-invalid" id="user_misc_5i" name="user[misc(5i)]">
#{options_range(start: "00", stop: "59", selected: "00")}
</select>
<div class="invalid-feedback">error for test</div>
</div>
<div class="invalid-feedback">error for test</div>
</div>
</form>
HTML
Expand Down Expand Up @@ -510,8 +510,8 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
<select class="form-control is-invalid" id="user_misc_5i" name="user[misc(5i)]">
#{options_range(start: "00", stop: "59", selected: "00")}
</select>
<div class="invalid-feedback">error for test</div>
</div>
<div class="invalid-feedback">error for test</div>
</div>
</form>
HTML
Expand Down

0 comments on commit 769cf00

Please sign in to comment.