forked from mjbellantoni/formtastic-bootstrap
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CheckBoxInput along with some Choices refactorings.
- Loading branch information
Matthew Bellantoni
committed
Nov 4, 2011
1 parent
df4c870
commit 79baa77
Showing
8 changed files
with
486 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module FormtasticBootstrap | ||
module Inputs | ||
class CheckBoxesInput < Formtastic::Inputs::CheckBoxesInput | ||
include Base | ||
include Base::Choices | ||
|
||
def to_html | ||
input_wrapping do | ||
legend_html << | ||
hidden_field_for_all << | ||
choices_wrapping do | ||
choices_group_wrapping do | ||
collection.map { |choice| | ||
choice_wrapping(choice_wrapping_html_options(choice)) do | ||
choice_html(choice) | ||
end | ||
}.join("\n").html_safe | ||
end | ||
end | ||
end | ||
end | ||
|
||
def choice_html(choice) | ||
template.content_tag(:label, | ||
hidden_fields? ? | ||
check_box_with_hidden_input(choice) : | ||
check_box_without_hidden_input(choice) << | ||
choice_label(choice), | ||
label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil) | ||
) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.