DVG
DVG

Reputation: 17470

simple_form a single non-model field

So I have a simple_form, and I want to use the standard j-Query datepicker to select the date.

Problem is, rails doesn't like the normal US MM/DD/YYYY date format, so I want to have the field for the display date and store the rails-compliant date format in a hidden field.

How do I tell simple_form to use a field that doesn't exist in the model?

Upvotes: 1

Views: 698

Answers (1)

pjammer
pjammer

Reputation: 9577

Not sure what you can't do, but i do something like:

$(".datepicker").datepicker({ altFormat: "yy-mm-dd", dateFormat: "yy-mm-dd" });

If configuring the datepicker doesn't work for you, use attr_accessor :new_field_name in your model and add the datepicker to it and do what you were going to do there.

Upvotes: 4

Related Questions