Skip to content

Loading…

Fixed prompts on select inputs #708

Merged
merged 1 commit into from

3 participants

@justinfrench
Owner

This looks good to me. @sobrinho ?

@sobrinho sobrinho merged commit fa26bdf into justinfrench:master
@sobrinho
Collaborator

It's ok, thanks!

@sobrinho
Collaborator

I reverted this pull request because broken another spec.

Could you check this @dim?

http://travis-ci.org/#!/justinfrench/formtastic/builds/208253

@justinfrench
Owner

@dim have you got time to see this through?

@justinfrench
Owner

@dim, apologies, just saw the other one had been sent and pulled in. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 5, 2011
  1. @dim

    Fixed prompts on select inputs

    dim committed
Showing with 11 additions and 9 deletions.
  1. +9 −8 lib/formtastic/inputs/select_input.rb
  2. +2 −1 spec/inputs/select_input_spec.rb
View
17 lib/formtastic/inputs/select_input.rb
@@ -162,20 +162,21 @@ def grouped_select_html
input_html_options
)
end
-
+
def include_blank?
- return options[:prompt] if options.key?(:prompt)
- return options[:include_blank] if options.key?(:include_blank)
- return true if (single? && builder.include_blank_for_select_by_default)
- false
- end
+ options[:include_blank] == true || (single? && builder.include_blank_for_select_by_default)
+ end
+
+ def prompt?
+ !!options[:prompt]
+ end
def label_html_options
super.merge(:for => input_html_options[:id])
end
def input_options
- super.merge({:include_blank => include_blank?, :prompt => nil})
+ super.merge :include_blank => include_blank? && !prompt?
end
def input_html_options
@@ -207,4 +208,4 @@ def single?
end
end
-end
+end
View
3 spec/inputs/select_input_spec.rb
@@ -432,7 +432,8 @@
output_buffer.should have_tag("form li select option[@value='']", /choose author/, :count => 1)
end
- it 'should not have a blank select option' do
+ it 'should not have a second blank select option' do
+ output_buffer.should have_tag("form li select option[@value='']", :count => 1)
output_buffer.should_not have_tag("form li select option[@value='']", "")
end
end
Something went wrong with that request. Please try again.