Datepicker ui 与 formattastic,rails 3.1

发布于 2024-12-26 01:55:37 字数 575 浏览 4 评论 0原文

我使用rails 3.1,formtastic 2.0.2和datepicker ui

我制作了datepicker_input.rb:

 class DatepickerInput < Formtastic::Inputs::StringInput
include Formtastic::Inputs::Base

    def input_html_options
        super.merge(:class => "datepicker")
    end 
 end

在application.js中我写道:

 $('input.datepicker').datepicker()

我在我的表单中使用它,例如:as =>; :日期选择器。我看到日历,选择日期,一切都很好,除了它没有填充我的模型中的列。我注意到的唯一一件事是,当我填写第一个日期,然后填写所有其他字段时 - 它起作用了。当日期字段是最后一个时 - 它不起作用。没有错误,params[:model_name][:date_field] 不为空,只是用 nil 代替我选择的日期。

I use rails 3.1, formtastic 2.0.2 and datepicker ui

I made datepicker_input.rb:

 class DatepickerInput < Formtastic::Inputs::StringInput
include Formtastic::Inputs::Base

    def input_html_options
        super.merge(:class => "datepicker")
    end 
 end

In application.js I wrote:

 $('input.datepicker').datepicker()

I use it in my form like :as => :datepicker. I see calendar, pick date and everything is fine except for it doesn't fill column in my model. The only thing that I noticed is that when I fill first date and then all the other fields - it works. When date field is the last - it doesn't work. There is no errors, params[:model_name][:date_field] is not empty just nil in place of date that I chose.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

友谊不毕业 2025-01-02 01:55:37

日期格式错误 - 数据库无法采用返回日期选择器的格式。

Error was in date format - database just couldn't take format that returned datepicker.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文