Default input type

26 views
Skip to first unread message

Sergey Nartimov

unread,
Mar 1, 2012, 2:45:47 AM3/1/12
to plataformate...@googlegroups.com
Сould you suggest a way to set default input type based on model metadata in SF?

There is method that can be monkey-patched https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/form_builder.rb#L376-402 but it isn't public API.

Thanks.

Rafael Mendonça França

unread,
Mar 1, 2012, 6:57:52 AM3/1/12
to plataformate...@googlegroups.com
Hey Sergey!

You can use the input_mappings configuration options.

Basically it is a colummn name => type mapping.

You can do things like:

config.input_mappings = { /_price/ => :decimal }

Sergey Nartimov

unread,
Mar 1, 2012, 7:09:04 AM3/1/12
to plataformate...@googlegroups.com
Thanks for reply.

We're writing SF integration to provide select field for string column
based on model metadata. So we don't want default input type to be
global for all models. That is why `input_mappings` can't be used in
our case. It's better if we can patch some method where model is
accessible and where default options can be set (in our case we need
to add `collection` option). Are there any other variants besides
patching `default_input_type` method?

Rafael Mendonça França

unread,
Mar 1, 2012, 8:36:14 AM3/1/12
to plataformate...@googlegroups.com
You can try to patch the input method. As you are in the FormBuilder you have access to the @object and you can change the options hash. But you need also to patch the default_input_type.

Do you have suggestions to improve this API?
Reply all
Reply to author
Forward
0 new messages