ruby - Formtastic, own :as input type -


how can add own field types formtastic ?

for exemple, need have custom datetime input, , want this:

<%= f.input :start_date , :as => :my_date %> 

this doesn't work because formtastic doesn't know :my_date (only :boolean, :string, :datetime , on...)

but how can add additional input types ?

you need add custom input method:

class mycustomformtasticformbuilder < formtastic::semanticformbuilder   protected   def my_date_input(method, options)     basic_input_helper(:text_field, :my_date, method, options)   end end 

that's perfect for, new html5 input types. use so:

<% form_form @model, :builder => mycustomformtasticformbuilder  |f| %>    <%= f.input :start_date, :as => :my_date <% end %> 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -