gpt4 book ai didi

ruby-on-rails - 选择标签在 rails 3.1 rc4 中包含空白行为

转载 作者:行者123 更新时间:2023-12-04 03:36:58 24 4
gpt4 key购买 nike

  <%= select_tag 'pseudo-attribute', options_for_select(...), :include_blank => 'Nowhere'%>

这个标签过去包含一个带有“Nowhere”的空白选项,但现在文本框是空白的,有人知道这是为什么吗?

最佳答案

现在 select 标签的代码是 (Rails 3.1.0.rc4)

  def select_tag(name, option_tags = nil, options = {})
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name

if options.delete(:include_blank)
option_tags = "<option value=\"\"></option>".html_safe + option_tags
end

if prompt = options.delete(:prompt)
option_tags = "<option value=\"\">#{prompt}</option>".html_safe + option_tags
end

content_tag :select, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
end

这意味着您必须将 :include_blank 替换为 :prompt。如果您想在选择字段中使用空白选项,请使用包含空白:)

关于ruby-on-rails - 选择标签在 rails 3.1 rc4 中包含空白行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6737751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com