如何将自定义名称和ID添加到time_select

时间:2016-06-19 08:33:16

标签: ruby-on-rails ruby

我已经time_select了,我想在输入中添加自定义名称和ID,我试过:

<td>
   <%= f_messenger.time_select :schedules,
       :id => "messenger_schedules_#{day}_end",
       :name => "messenger[schedules][#{day}][end]"
   %>
</td>

如果我尝试使用文本输入它可以工作,但在time_select我得到类似的东西:

<select id="messenger_schedules_4i" name="messenger[schedules(4i)]">

任何想法?

1 个答案:

答案 0 :(得分:0)

来自documents

您可以尝试以下代码:

<td>
   <%= f_messenger.time_select :schedules, '', prompt: {}, 
     id: "messenger_schedules_#{day}_end",
     name: "messenger[schedules][#{day}][end]"
   %>
</td>