JavaScript simple_form Custom inputs

lshgood · January 16, 2013 · 2481 hits

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 =>
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.