Rafael,
I am getting a similar 'Could not find method for :timepicker' error
for the input method when declaring the custom input class:
class TimepickerInput < SimpleForm::Inputs::StringInput # Assume
you meant the StringInput class, not String
end
Seems like ruby can't find the input method in the
SimpleForm::Inputs::StringInput class. In case it is useful I put my
whole simple_form below.
Please let me know if you have any tips on what the cause can be to
this error.
Btw, if I remove the calls to the custom input methods the form works
fine.
Best,
Andy
MY FORM:
= simple_form_for @event do |f|
= f.input :title, :as => :string, :required => true, :hint =>
"Example: Amazing French cuisine."
= f.input :details, :as => :text, :hint => "Example: We will
start with Crepes and then have Souffle for dessert."
/= f.input :cost, :as => :currency, :hint => "Example: 25"
= f.input :max_seats, :label => "How many seats?", :as
=> :numeric, :hint => "Example: 5"
= f.input :end, :as => :timepicker
= f.input :address, :as => :string, :hint => "Input the
address of the venue here."
#demo4_map{:style => "width:400px;height:300px;"}
= f.input :lat, :as => :hidden
= f.input :lng, :as => :hidden
= f.button :submit
On May 22, 10:49 am, Rafael Mendonça França <
rafaelmfra...@gmail.com>
wrote:
> The second option is the best way to do this. But if you do it like Carlos said you will change the behavior of all datatime inputs.
>
> I recommend that you create a new input type and use it in the :as options.
>
> Eg.:
>
> # app/inputs
> class TimepickerInput < SimpleForm::Inputs::String
> end
>
> f.input :start, :as => :timepicker
> --
> Rafael Mendonça França
> Software developer at Plataformatechttp://
twitter.com/rafaelfrancahttps://github.com/rafaelfranca
> Sent with Sparrow
>
> On Sunday, 22 May, 2011 at 11:44, Carlos Antonio da Silva wrote:
>
>
>
> > Well, you can use the input helper + :as option as string, like this:
>
> > f.input :start, :as => :string
>
> > This would give you a pretty similar output.
> > If you want *all* your datetime inputs to be used as date/time, you have some options:
>
> > * Create a CustomFormBuilder and re-map the date / time / datetime options to string, by calling map_type (there is a section about custom form builders in the README):
https://github.com/plataformatec/simple_form/blob/master/lib/simple_f...
>
> > map_type :date, :time, :datetime, :to => SimpleForm::Inputs::StringInput
>
> > * Create a custom input inside your app/inputs folder, and inheriting them from StringInput:
>
> > class DateTimeInput < SimpleForm::Inputs::String
> > end
>
> > * Or, you can re-map the date time input in SimpleForm itself, although I think that should be the last option =). You would probably need to call sth like this in an initializer:
>
> > SimpleForm::FormBuilder.map_type :date, :time, :datetime, :to => SimpleForm::Inputs::StringInput
>
> > This should override SimpleForm default behavior.
>
> > Please let me know if any of these works for you.
>