diff options
author | Serj Prikhodko <sergey.prikhodko@toptal.com> | 2018-02-22 21:37:15 +0300 |
---|---|---|
committer | Serj Prikhodko <sergey.prikhodko@toptal.com> | 2018-02-27 23:36:05 +0300 |
commit | 9afec1639d42d7d9a496775cd5239fedce27ec22 (patch) | |
tree | 87ba58a21658d305154d366fad6cc9c3c71b7d50 /actionview/lib/action_view | |
parent | 39d2cde65919729ec1ca3663d7872adf8036fd58 (diff) | |
download | rails-9afec1639d42d7d9a496775cd5239fedce27ec22.tar.gz rails-9afec1639d42d7d9a496775cd5239fedce27ec22.tar.bz2 rails-9afec1639d42d7d9a496775cd5239fedce27ec22.zip |
Let select render default selected option for required field
Diffstat (limited to 'actionview/lib/action_view')
-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 |