2011-07-18 74 views

回答

8

現在的選擇標記的代碼是(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。使用包括空白,如果你想在你的選擇領域的空白選項:)