2
<%= select_tag 'pseudo-attribute', options_for_select(...), :include_blank => 'Nowhere'%>
このタグは空白のオプションを「Nowhere」に含めましたが、現在はテキストボックスが空白になっています。選択タグはレール3.1で空白の動作を含みます。rc4
<%= select_tag 'pseudo-attribute', options_for_select(...), :include_blank => 'Nowhere'%>
このタグは空白のオプションを「Nowhere」に含めましたが、現在はテキストボックスが空白になっています。選択タグはレール3.1で空白の動作を含みます。rc4
今のselectタグ用のコードは、あなたが:prompt
で:include_blank
を交換する必要が意味している
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
(Railsの3.1.0.rc4)です。選択フィールドに空白のオプションが必要な場合は、空白を使用してください:)