Rails 日期选择在空白时为月份分配一个值
我使用 Rails date_select 如下:
<%= date_select :user, :birthday, {:start_year => Time.now.year, :end_year => 1910,:order => [:day,:month,:year], :prompt => { :day => 'day', :month => 'month', :year => 'year' }}, { :class => "default" } %>
当用户忘记输入日期或月份的值并在将信息放入模型时提交表单时,会生成错误。但是,日期和月份字段也被分配为 1。这会导致表单显示日期字段为 1,月份字段显示为 1 月。
我怎样才能阻止这种情况发生?
I am using Rails date_select as follows:
<%= date_select :user, :birthday, {:start_year => Time.now.year, :end_year => 1910,:order => [:day,:month,:year], :prompt => { :day => 'day', :month => 'month', :year => 'year' }}, { :class => "default" } %>
When a user forgets to enter a value for the day or month and submit the form when the information is put into the model an error is generated. However the day and month fields also get assigned to 1. This results in the form showing 1 for the day field and January for the month field.
How can I stop this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论