加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – simple_form f.hidden_??field有效,为什么不f.

发布时间:2020-12-16 23:30:34 所属栏目:百科 来源:网络整理
导读:= 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,:value = @some.thin
= 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,:value => @some.thing

当我查看我的日志时,我看到该值在后一个输入中以空字符串形式出现,但我不清楚为什么会发生这种情况.

解决方法

f.hidden_??field是 ActionView::Helpers::FormHelper,而f.input属于 SimpleForm.

语法类似但有一些差异.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读