简体   繁体   中英

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.

<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))

Where render_field is the following:

# 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)

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

end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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