如何在formtastic 1.2.4字段中指定自定义类?

时间:2012-07-02 21:22:09

标签: formtastic

我有这个自定义表单构建器,它调用:

basic_input_helper(:text_field, :date, :date_value, options.merge!({:html_options => {:class => "datepicker"}})) if options[:response_class] == "date"

第四个参数有选项(html选项,如果我正确读取代码),我希望该行将class="datepicker"添加到我的输入字段,但我得到:

<input id="r_3_date_value" name="r[3][date_value]" size="30" type="text" value="2012-07-02" />

根本没有class属性。我错过了什么?

1 个答案:

答案 0 :(得分:1)

您必须使用密钥:input_html代替:html_options

basic_input_helper(:text_field, :date, :date_value, options.merge!({:input_html => {:class => "datepicker"}})) if options[:response_class] == "date"

代码得到评估like this (source on github),您可以在第647行看到输入html的评估

相关问题