0

selectすべての選択ボックスがdisabledデフォルトで属性を取得するように、 Rails のメソッドをカスタム フォーム ヘルパーでオーバーライドしようとしています。

class LabelFormBuilder < ActionView::Helpers::FormBuilder

  def select(method, choices, options = {}, html_options = {})
    html_options.reverse_merge! :disabled => true
    super(method, choices, options = {}, html_options = {})
  end

end

問題は、コードが機能せず、選択ボックスのレンダリング方法が何も変更されないことです。エラーも出ません。

これは、関数を呼び出すために使用するビュー コードです。

<%= f.select(:person_id, current_user.person_names, {:prompt => 'Please select...'}) %>

ここで何が欠けていますか?

助けてくれてありがとう...

4

1 に答える 1

0

たぶん試してみてください

<%= f.select(:person_id, current_user.person_names, {}, {:prompt => 'Please select...'}) %>
于 2012-11-10T19:17:55.650 に答える