使用 date_field_tag 防止输入上一个日期 [英] Prevent Input of previous Date with date_field_tag
问题描述
Rails 4 FormTagHelper date_field_tag 是否有一个选项允许我阻止用户选择当前日期之前的日期?
Is there an option with the Rails 4 FormTagHelper date_field_tag which allows me to prevent users from selecting a date previous to the current?
推荐答案
好吧,检查文档 date_field_tag 的语法如下:
Well, checking the documentation the sintax for date_field_tag is the following:
datetime_field_tag(name, value = nil, options = {})
datetime_field_tag(name, value = nil, options = {})
选项接受诸如 (:min, :max) 之类的参数
The options accepts arguments such as (:min, :max)
我不喜欢 Rails4,但您可能可以声明一个保存当前日期的变量,然后将其作为 ':min' 参数的值传递,例如:
Im not fond of Rails4, but you could probably declare a variable that holds the current day date and then pass it as a value for the ':min' argument, something like:
datetime_field_tag(name, value = nil, options = {:min=> @todayvariable})
希望能帮到你
这篇关于使用 date_field_tag 防止输入上一个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!