2012-04-21 39 views

回答

0

我不知道你爲什麼會想這樣做,但我相信你能不能做到這一點。看代碼爲check_box_tag幫手:

def check_box_tag(name, value = "1", checked = false, options = {}) 
    html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys) 
    html_options["checked"] = "checked" if checked 
    tag :input, html_options 
end 

你可以做的最接近的是通過,這將產生id=""

+0

我只是不需要一個id爲錶行每複選框。我用的名字'model_ids []',這樣複選框進行分組。 ID最終是彼此重複的。順便說一句,空ID是無效的。 http://stackoverflow.com/questions/6535934/is-an-id-allowed-to-be-empty-in-an-html-tag – m33lky 2012-04-21 04:44:03