在time_select字段中将引导类添加到rails [英] Adding a bootstrap class to rails form time_select field

查看:43
本文介绍了在time_select字段中将引导类添加到rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bootstrap具有类"form-control",可添加到选择框以为其提供样式.我能够成功完成以下操作:

Bootstrap has the class 'form-control' to add to select boxes to give them styling. I was able to do it successfully so for the following field:

 <%= f.collection_select :team_a_id, @teams, :id, :name, {prompt: "Select first team"}, {class: "form-control"} %>

但是,对于time_select,我具有以下表单字段.我需要将html类(最好是"form-control")应用于以下表单字段,并且使用上述相同方法未能成功完成此操作.

However I have the following form field for time_select. I need to apply an html class(preferably "form-control") to the following form field and have not been successful in doing so with the same approach above.

 <%= f.time_select :match_time, prompt: {hour: 'Choose hour', minute: 'Choose minute'}, minute_step: 15 %>

我将如何解决这个问题?

How would I approach this problem?

推荐答案

html_options是第三个参数,如

The html_options is the third parameter, as described in the docs:

time_select(method, options = {}, html_options = {})

所以这样的事情应该起作用:

so something like this should work:

 <%= f.time_select :method, { prompt: {hour: 'Choose hour', minute: 'Choose minute'}, minute_step: 15 }, { class: 'form-control' } %>

这篇关于在time_select字段中将引导类添加到rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆