Skip to content

Conversation

danielvlopes
Copy link
Contributor

Hello, Today when we want a select_tag with a prompt we need to pass :include_bank => "My Prompt". I think this is incoherent with the select method from form builders. Also, the documentation don't cover this behavior, which means, to know about include_blank with string people should read the source code.

My small pull request make select_tag behave like select and add docs from prompt and include blank.

Thanks.

@josevalim
Copy link
Contributor

Merged. Could you also please check if we could refactor f.select, f.time_zone_select and friends now that prompt is on select_tag?

josevalim added a commit that referenced this pull request May 3, 2011
Select_tag should have the same API of select from form_builder
@josevalim josevalim merged commit dd7afdb into rails:master May 3, 2011
@danielvlopes
Copy link
Contributor Author

Do you mean refactor f.select (and others) to use select_tag under the hood?

On terça-feira, 3 de maio de 2011 at 12:01, josevalim wrote:

Merged. Could you also please check if we could refactor f.select, f.time_zone_select and friends now that prompt is on select_tag?

Reply to this email directly or view it on GitHub:
#378 (comment)

@josevalim
Copy link
Contributor

Ah, those helpers don't use select_tag? So there is nothing to change then. :)

@danielvlopes
Copy link
Contributor Author

Actualy they don't user the select_tag helper but do something similar

def select(object, method, choices, options = {}, html_options = {})
  InstanceTag.new(object, method, self, options.delete(:object)).to_select_tag(choices, options, html_options)
end

def to_select_tag(choices, options, html_options)
  html_options = html_options.stringify_keys
  add_default_name_and_id(html_options)
  value = value(object)
  selected_value = options.has_key?(:selected) ? options[:selected] : value
  disabled_value = options.has_key?(:disabled) ? options[:disabled] : nil
  content_tag("select", add_options(options_for_select(choices, :selected => selected_value, :disabled => disabled_value), options, selected_value), html_options)
end

Maybe I could refactor to_select_tag to call select_tag.

@josevalim
Copy link
Contributor

That may be worth a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants