JavaScript simple_form Custom inputs

lshgood · 2013年01月16日 · 2478 次阅读

https://github.com/lshgo/simple_form_chosen

simple_form Custom inputs 还不错

 # app/inputs/chosen_input.rb

 class ChosenInput < SimpleForm::Inputs::Base
  def input
    # "$ #{@builder.text_field(attribute_name, input_html_options)}".html_safe 
  end
end
f.input :money, :as => :chosen

collection 集合。

# app/inputs/collection_select_input.rb

class CollectionSelectInput < SimpleForm::Inputs::CollectionSelectInput
  def input_html_classes
    super.push('chosen')
  end
end
f.input :money, :as => :collection, :collection =>
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号