作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
例如,如果我有一个名为 start_time
的时间属性的简单模型。 ,那么直接的表单代码将是...
<%= form_for newObj do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<div class="field">
<%= f.label :start_time %><br />
<%= f.text_field :start_time %>
</div>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
time
的日期组件。对象和一个用于
time
的时间组件目的。
最佳答案
我认为这可能不是您问题的直接答案,但可能会提供一个很好的起点:
有一个 Rails View 助手 select_datetime
它为日期和时间条目(而不是文本字段)生成下拉菜单。参见文档:http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-select_datetime
Ryan Bates 做了几个相关的 railscasts(链接是 asciicasts,应该包含原始视频的链接):
关于ruby-on-rails - rails 3 : How do I write forms that don't align exactly with the structure of the model?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5759249/
我是一名优秀的程序员,十分优秀!