cannot set up my first custom input correctly... No input found for

329 views
Skip to first unread message

erwin

unread,
Sep 28, 2012, 9:28:20 AM9/28/12
to SimpleForm
I am trying to write my first custom input, first to test the setup,
but it seems that I did not get it right the first time

In my view , I wrote the simple_form input like this :

= f.input :starts_at, :as => :mystuff, :input_html => {:value =>
"12/02/2013" }, :class => "span2"


I have put in app/inputs/mystuff.rb

class MystuffInput < SimpleForm::Inputs::StringInput
def input
debugger
super
end
end

In my config/application.rb , I have autoload paths :
config.autoload_paths += Dir["#{config.root}/lib", "#{config.root}/lib/
**/", "#{config.root}/app/inputs"]

And finally in my config/initializers/simple_form.rb , I have :

config.input_mappings = { /mystuff/ => :mystuff }
config.inputs_discovery = true

I thought my setup was complete, but on form view display, I get :
RuntimeError in Backoffice/events#new

No input found for mystuff

The trace show that the error happen in the mapping ...
simple_form (2.0.2) lib/simple_form/form_builder.rb:441:in
`find_mapping'
simple_form (2.0.2) lib/simple_form/form_builder.rb:372:in
`find_input'
simple_form (2.0.2) lib/simple_form/form_builder.rb:115:in `input'
app/views/backoffice/events/new.html.haml:12:in `block in
_app_views_backoffice_events_new_html_haml__3541661266551348407_70152580768420'

what is wrong in my initialization ?

thanks for feedback


erwin

unread,
Sep 29, 2012, 2:56:26 AM9/29/12
to SimpleForm
Digging into simple_form code, I found ( I guess) that custom input is
based on the original attribute column type... so mystuff doesn't
exist... beacsue the column type of 'starts_at' is datetime

I wrote successfully , my first custom input, to replace the
simple_form datetime with a custom bootstrap datepicker

class DateTimeInput < SimpleForm::Inputs::DateTimeInput
Reply all
Reply to author
Forward
0 new messages