【问题标题】:Including a manual Rails tag in my form's parameters在我的表单参数中包含手动 Rails 标记
【发布时间】:2010-09-23 22:25:35
【问题描述】:

这个问题与另一个问题有关: Change rails text_field form builder type

我的表单中有一个 JQuery 工具范围,要使其正常工作需要输入字段的类型为“日期”。 Rails 不允许我这样做,所以我使用了手动标记,如下所示:

<% form_for @customer, :url => {:action => "update", :id => @customer} do |f| %>
...
<%= tag(:input, {:type => :range, :value => f.object.travel, :name => "travel", :min => "0", :max => "100" }) %>
...
<% end %>

此标签显示范围滑块。它还显示数据库中的正确值。但是,当我提交更改时,“旅行”属性作为通用属性发送,而不是在“客户”下。所以,我的数据库没有更新。

如何重写标签以使其作为“客户”属性包含在内?

【问题讨论】:

    标签: html ruby-on-rails tags jquery-tools


    【解决方案1】:

    试试:

    <%= tag(:input, {:type => :range, :value => f.object.travel, :name => "customer[travel]", :min => "0", :max => "100" }) %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 2011-02-09
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多