【问题标题】:I only want certain hours on my rails time_select form我只希望我的 rails time_select 表单上有几个小时
【发布时间】:2017-02-09 16:32:05
【问题描述】:

在我的应用中,用户应该只能选择上午 10 点到中午 12 点之间的时间,然后是下午 4 点到下午 6 点之间的时间。基本上我希望我的“小时”下拉菜单只列出“上午 10 点、上午 11 点、下午 12 点”和“下午 4 点、下午 5 点、下午 6 点”。这可能吗?

【问题讨论】:

    标签: ruby-on-rails forms form-helpers time-select


    【解决方案1】:
    <%= f.time_select :time,
    {ampm: true,
    ignore_date: true,
    start_hour: 10, 
    end_hour: 18,
    discard_minute: true,
    prompt: true,
    prompt: { hour: "Choose hr" }
    } %>
    

    可以开始吗?也许您可以编写一个脚本来禁用其他时间,或者您使用 JavaScript 为您生成 html 选项?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-07
      • 1970-01-01
      • 2022-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 2021-05-23
      相关资源
      最近更新 更多