简体   繁体   English

Ruby-Rails-只读文本值形式输入

[英]Ruby - rails - read only text value form input

How do I print simple text to be a form value and make it non editable? 如何将简单文本打印为表单值并使之不可编辑? I am not looking for 我不是在找

<%= text_field_tag :something, nil, :readonly => true %>

I want it without a read only input box. 我希望它没有只读输入框。 Like html and still get posted via the form. 像html一样,仍然可以通过表单发布。

<a id="something"></a>
<%= hidden_field_tag ... %>
<%= your_variable_here_with_whatever_format_you_want %>

render_field(field, prefix, options.merge(:hide_description => true, :readonly => true)) render_field(字段,前缀,options.merge(:hide_description => true,:readonly => true))

Where render_field is the following: 其中render_field是以下内容:

# Returns html def render_field(field, prefix = "", options = {}) hidden = field.fetch("HIDDEN", false) return if hidden field_type = field["TYPE_KIND"].upcase return "Unkown field type #{field_type}" unless %w(CNDGP).include?(field_type) #返回html def render_field(field,prefix =“”,options = {})hidden = field.fetch(“ HIDDEN”,false)返回,如果hidden field_type = field [“ TYPE_KIND”]。upcase返回“未知字段类型#{ field_type}“,除非%w(CNDGP).include?(field_type)

send("render_#{field_type.downcase}_type", *[field, prefix, options])

end 结束

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

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