forked from NUBIC/surveyor
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding date and time fields to pick one and pick any. closes NUBIC#207
- Loading branch information
Mark Yoon
committed
May 22, 2012
1 parent
70f9910
commit db28f52
Showing
6 changed files
with
68 additions
and
10 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,17 @@ | ||
module Surveyor | ||
module Helpers | ||
module FormtasticCustomInput | ||
def input_html_options_with(choice, response_class) | ||
input_html_options.merge(choice_html_options(choice)).merge({:id => (input_html_options[:id] || "answer_id").gsub("answer_id", response_class_to_method(response_class).to_s), :class => [input_html_options[:class], response_class].join(" ")}) | ||
end | ||
def response_class_to_method(response_class) | ||
# doesn't handle response_class == answer, and doesn't have to | ||
case response_class.to_s | ||
when /^other_and_string$/ then :string_value | ||
when /^date|time$/ then :datetime_value | ||
else "#{response_class}_value".to_sym | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
require File.expand_path(File.dirname(__FILE__) + '/../../lib/surveyor/helpers/formtastic_custom_input') | ||
|
||
describe Surveyor::Helpers::FormtasticCustomInput do | ||
context "input helpers" do | ||
it "should translate response class into attribute" do | ||
helper.response_class_to_method(:string).should == :string_value | ||
helper.response_class_to_method(:other_and_string).should == :string_value | ||
helper.response_class_to_method(:integer).should == :integer_value | ||
helper.response_class_to_method(:float).should == :float_value | ||
helper.response_class_to_method(:datetime).should == :datetime_value | ||
helper.response_class_to_method(:date).should == :datetime_value | ||
helper.response_class_to_method(:time).should == :datetime_value | ||
end | ||
end | ||
end |