简体   繁体   English

simple_form f.hidden_​​field有效,为什么不f.input?

[英]simple_form f.hidden_field works, why not f.input?

= simple_form_for @foo do |f|

  # this works
  = f.hidden_field :asdf, :value => @some.thing

  # this works
  = f.input :asdf, :as => "hidden", :input_html => { :value => @some.thing }

  # Why doesn't this work, exactly?
  = f.input :title, :as => "hidden", :value => @some.thing

When I look at my log I see that value is coming through as an empty string in the latter input, but it's not clear to me why this is happening. 当我查看我的日志时,我看到该值在后一个输入中以空字符串形式出现,但我不清楚为什么会发生这种情况。

f.hidden_field is a ActionView::Helpers::FormHelper while f.input belongs to SimpleForm . f.hidden_field是一个ActionView :: Helpers :: FormHelper,f.input属于SimpleForm

The syntax is similar but has some differences. 语法类似但有一些差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM