diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-02-27 22:52:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-27 22:52:54 -0500 |
commit | a14a6b8834fc35136aa0e52bb27fd73f75f83c0b (patch) | |
tree | d885a87dba369c923073358ba159a1e5d20593ac /actionview/lib | |
parent | ea86da84aa89f2e7532dfc9b33ea0b033b56f16c (diff) | |
parent | 9afec1639d42d7d9a496775cd5239fedce27ec22 (diff) | |
download | rails-a14a6b8834fc35136aa0e52bb27fd73f75f83c0b.tar.gz rails-a14a6b8834fc35136aa0e52bb27fd73f75f83c0b.tar.bz2 rails-a14a6b8834fc35136aa0e52bb27fd73f75f83c0b.zip |
Merge pull request #32087 from prikha/add-better-select-tag-option-handling
Let select render default selected option for required field
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/helpers/tags/base.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index fed908fcdb..f1eca2268a 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -170,7 +170,11 @@ module ActionView option_tags = tag_builder.content_tag_string("option", options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, value: "") + "\n" + option_tags end if value.blank? && options[:prompt] - option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), value: "") + "\n" + option_tags + tag_options = { value: "" }.tap do |prompt_opts| + prompt_opts[:disabled] = true if options[:disabled] == "" + prompt_opts[:selected] = true if options[:selected] == "" + end + option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), tag_options) + "\n" + option_tags end option_tags end |