2
<%= select_tag 'pseudo-attribute', options_for_select(...), :include_blank => 'Nowhere'%>
此標籤用於包含一個空白選項與「無處」,但現在文本框是空白的,有誰知道這是爲什麼?選擇標籤在rails中包含空白行爲3.1 rc4
<%= select_tag 'pseudo-attribute', options_for_select(...), :include_blank => 'Nowhere'%>
此標籤用於包含一個空白選項與「無處」,但現在文本框是空白的,有誰知道這是爲什麼?選擇標籤在rails中包含空白行爲3.1 rc4
現在的選擇標記的代碼是(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
,這意味着你有:prompt
更換:include_blank
。使用包括空白,如果你想在你的選擇領域的空白選項:)