Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Removed double label on boolean inputs, and changed to input-mini/input-small on date/time selects #39

Closed
wants to merge 6 commits into from

4 participants

@accidental

Boolean:
This was adding the label twice, once as a normal label on the left and again as a checkbox wrapped with the label. I've commented out the first label since this seems un-necessary.

Timeish:
I found date and time selects were ending up on separate lines because of the way the fluid boostrap css converts span1 and span2 to block elements. Switching to input-mini (and input-small for month) fixed this. There was also a placeholder named after the class being added to the selects which is un-necessary. I commented this out.

@accidental

I've added another fix so that inline errors are correctly inside the div.controls

@michaek

The doubling of labels on boolean inputs isn't good, but I'm not sure this is the right way to fix it. It seems like it should be up to the developer to decide whether to hide the control label (above the checkbox) or the inline label (beside the checkbox) as either may be appropriate depending on the form design.

Also, it seems like there are a lot of commits on this pull request, which might make the maintainer reluctant to merge it all in.

@cluesque cluesque referenced this pull request
Merged

Only label a checkbox once #46

@Mehonoshin

+1 waiting for fixing this issue

@sodabrew
Collaborator

I merged #46. If there are further changes in this PR you'd like to pursue, please rebase and comment here!

An update should not have any commented out code -- either the code is incorrect and must be actually removed, or your changes must support existing functionality without breaking.

@sodabrew
Collaborator

Closing for lack of updates. I think the issues in the PR have been resolved in the codebase more recently. Please do reopen or open new PRs if I am mistaken. Thanks!

@sodabrew sodabrew closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 6, 2012
  1. @accidental

    remove placeholders from date time selects and change input classes t…

    accidental authored
    …o input-mini, input-small instead of spans
  2. @accidental
Commits on Sep 28, 2012
  1. @accidental

    fix inline errors

    accidental authored
Commits on Oct 9, 2012
  1. @accidental

    hint_html on check_boxes

    accidental authored
  2. @accidental
Commits on Oct 12, 2012
  1. @accidental
This page is out of date. Refresh to see the latest.
View
2  lib/formtastic-bootstrap/form_builder.rb
@@ -33,7 +33,7 @@ def self.default_hint_class=(hint_class)
include FormtasticBootstrap::Helpers::InputsHelper
include FormtasticBootstrap::Helpers::ActionHelper
include FormtasticBootstrap::Helpers::ActionsHelper
- # include Formtastic::Helpers::ErrorsHelper
+ include FormtasticBootstrap::Helpers::ErrorsHelper
end
View
2  lib/formtastic-bootstrap/helpers.rb
@@ -3,7 +3,7 @@ module Helpers
autoload :ActionHelper, 'formtastic-bootstrap/helpers/action_helper'
autoload :ActionsHelper, 'formtastic-bootstrap/helpers/actions_helper'
- # autoload :ErrorsHelper, 'formtastic/helpers/errors_helper'
+ autoload :ErrorsHelper, 'formtastic-bootstrap/helpers/errors_helper'
autoload :FieldsetWrapper, 'formtastic-bootstrap/helpers/fieldset_wrapper'
# autoload :FileColumnDetection, 'formtastic/helpers/file_column_detection'
# autoload :FormHelper, 'formtastic/helpers/form_helper'
View
30 lib/formtastic-bootstrap/helpers/errors_helper.rb
@@ -0,0 +1,30 @@
+module FormtasticBootstrap
+ module Helpers
+ module ErrorsHelper
+
+ include Formtastic::Helpers::ErrorsHelper
+
+ def semantic_errors(*args)
+ html_options = args.extract_options!
+ args = args - [:base]
+ full_errors = args.inject([]) do |array, method|
+ attribute = localized_string(method, method.to_sym, :label) || humanized_attribute_name(method)
+ errors = Array(@object.errors[method.to_sym]).to_sentence
+ errors.present? ? array << [attribute, errors].join(" ") : array ||= []
+ end
+ full_errors << @object.errors[:base]
+ full_errors.flatten!
+ full_errors.compact!
+ return nil if full_errors.blank?
+ html_options[:class] ||= "errors"
+ template.content_tag(:div, :class => 'alert alert-error alert-block') do
+ Formtastic::Util.html_safe( '<button type="button" class="close" data-dismiss="alert">&times;</button>' + "\n") +
+ template.content_tag(:ul, html_options) do
+ Formtastic::Util.html_safe(full_errors.map { |error| template.content_tag(:li, Formtastic::Util.html_safe(error)) }.join)
+ end
+ end
+ end
+
+ end
+ end
+end
View
20 lib/formtastic-bootstrap/inputs/base/timeish.rb
@@ -30,24 +30,24 @@ def fragment_input_html_options(fragment)
input_html_options.tap do |options|
options[:id] = fragment_id(fragment)
options[:class] = ((options[:class] || "").split << fragment_class(fragment)).join(" ")
- options[:placeholder] = fragment_placeholder(fragment)
+ #options[:placeholder] = fragment_placeholder(fragment)
end
end
def fragment_class(fragment)
{
- :year => "span1",
- :month => "span2",
- :day => "span1",
- :hour => "span1",
- :minute => "span1",
- :second => "span1"
+ :year => "input-mini",
+ :month => "input-small",
+ :day => "input-mini",
+ :hour => "input-mini",
+ :minute => "input-mini",
+ :second => "input-mini"
}[fragment]
end
- def fragment_placeholder(fragment)
- "." + fragment_class(fragment)
- end
+ #def fragment_placeholder(fragment)
+ # "." + fragment_class(fragment)
+ #end
end
end
View
4 lib/formtastic-bootstrap/inputs/base/wrapping.rb
@@ -22,13 +22,13 @@ def bootstrap_wrapping(&block)
def control_group_wrapping(&block)
template.content_tag(:div,
- [template.capture(&block), error_html].join("\n").html_safe,
+ template.capture(&block).html_safe,
wrapper_html_options
)
end
def controls_wrapping(&block)
- template.content_tag(:div, template.capture(&block).html_safe, controls_wrapper_html_options)
+ template.content_tag(:div, [template.capture(&block), error_html].join("\n").html_safe, controls_wrapper_html_options)
end
def controls_wrapper_html_options
View
2  lib/formtastic-bootstrap/inputs/boolean_input.rb
@@ -6,7 +6,7 @@ class BooleanInput < Formtastic::Inputs::BooleanInput
def to_html
control_group_wrapping do
- control_label_html <<
+ #control_label_html <<
hidden_field_html <<
controls_wrapping do
label_with_nested_checkbox
View
2  lib/formtastic-bootstrap/inputs/check_boxes_input.rb
@@ -14,7 +14,7 @@ def to_html
controls_wrapping do
collection.map { |choice|
choice_html(choice)
- }.join("\n").html_safe
+ }.join("\n").html_safe + hint_html
end
end
end
Something went wrong with that request. Please try again.