# How to set a text\_field to un-editable in ROR

**URL:** <https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194>\
**Category:** Rails\
**Created:** [December 5, 2007, 1:20pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194 "2007-12-05T13:20:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 5, 2007, 1:20pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/1 "2007-12-05T13:20:06Z")

</div>

hi all

pls can any one tell me how to set a text\_field to un-editable in ROR.

i have to set a values for it and have to make it un-editable.

pls can some body help on this.

Thanks

---

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 5, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/2 "2007-12-05T14:10:44Z")

</div>

add a ‘disabled’ =\> ‘true’, e.g.

\<%= text\_field ‘post’, ‘title’, ‘size’ =\> 30, ‘disabled’ =\> ‘true’ %\>

On Dec 5, 4:20 am, Nadeesha M. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 5, 2007, 2:37pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/3 "2007-12-05T14:37:43Z")

</div>

On 05 Dec 2007, at 14:10, rubynuby wrote:

> add a ‘disabled’ =\> ‘true’, e.g.
> 
> \<%= text\_field ‘post’, ‘title’, ‘size’ =\> 30, ‘disabled’ =\> ‘true’ %\>

The XHTML definition clearly states it should be  
disabled=“disabled” ([http://www.w3schools.com/xhtml/xhtml\_syntax.asp](http://www.w3schools.com/xhtml/xhtml_syntax.asp))  
I also prefer the use of symbols for extra parameters.

\<%= text\_field “post”, “title”, :size =\> 30, :disabled =\> “disabled” %\>

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 5, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/4 "2007-12-05T16:31:51Z")

</div>

On Dec 5, 5:37 am, Peter De Berdt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= text\_field “post”, “title”, :size =\> 30, :disabled =\> “disabled” %\>
> 
> Best regards
> 
> Peter De Berdt

thank you for the correction. I did use symbols in my code but  
looking at the doc

> **[ActionView::Helpers::FormHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M000506)**
>
> Form helpers are designed to make working with resources much easier compared to using vanilla HTML.

it uses strings, so I changed it.

One of the more confusingg aspects of Ruby. sometimes it seems  
strings and symbols are interchangeable, and sometimes they’re not.

---

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 5, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/5 "2007-12-05T16:33:37Z")

</div>

If you pass :disabled =\> true, rails will properly spit out  
disabled=“disabled”.

-Bill

---

<div class="post-metadata">

**Author:** ![nad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@nad](https://www.ruby-forum.com/u/nad)\
**Post date:** [December 6, 2007, 4:35am UTC](https://www.ruby-forum.com/t/how-to-set-a-text-field-to-un-editable-in-ror/122194/6 "2007-12-06T04:35:29Z")

</div>

William P. wrote:

> If you pass :disabled =\> true, rails will properly spit out  
> disabled=“disabled”.
> 
> -Bill

Hi guys,

thanks a lot for the reply specially with the correct descriptions and  
telling what the actual process happen in Ruby.

thanks  
nadeesha
