# Reducing the length of stupid Textfield

**URL:** <https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209>\
**Category:** Rails\
**Created:** [February 28, 2007, 9:53pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209 "2007-02-28T21:53:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2007, 9:53pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/1 "2007-02-28T21:53:17Z")

</div>

Is it possible to reduce the length of the text field in a form? I  
used :size =\> 5, it does not reduce the size of text field shown on  
the screen. It is very long. TIA.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2007, 10:07pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/2 "2007-02-28T22:07:22Z")

</div>

> Is it possible to reduce the length of the text field in a form? I  
> used :size =\> 5, it does not reduce the size of text field shown on  
> the screen. It is very long. TIA.

Odds are it’s being styled via CSS. Try adding:

:style =\> “width: 100px”

And see if that shortens it… if so, CSS is styling it and you’ll have  
to  
decide where to modify it.

-philip

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 28, 2007, 10:08pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/3 "2007-02-28T22:08:54Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Is it possible to reduce the length of the text field in a form? I  
> used :size =\> 5, it does not reduce the size of text field shown on  
> the screen. It is very long. TIA.

Use CSS Formatting to reduce the size of the textfield.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 1, 2007, 1:58am UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/4 "2007-03-01T01:58:53Z")

</div>

> Is it possible to reduce the length of the text field in a form?  
> I used :size =\> 5

You need to put the size in quotes:  
:size =\> “5”

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 1, 2007, 2:49am UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/5 "2007-03-01T02:49:56Z")

</div>

:size =\> 5 in the options hash should work:

text\_field\_tag “name”, value = “”, options = {:size =\> 5}

That yields a text field with size 5 for me. So does:

f.text\_field :first\_name, {:size =\> 5}

Make sure there’s no CSS forcing the field to be longer.

Hope that helps…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 1, 2007, 2:53pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/6 "2007-03-01T14:53:34Z")

</div>

I’m not sure that’s true, Bill. I’ve been using :size =\> 20 [any number  
will  
do] on my fields for months [if not longer] and they work just fine. It  
even  
autoconverts them to the quoted string values that are proper XHTML. I’m  
using Edge Rails if that makes a difference.

RSL

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 1, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/reducing-the-length-of-stupid-textfield/87209/7 "2007-03-01T21:31:40Z")

</div>

It does not matter whether it is within double quotes. Thanks for the  
help, the CSS was forcing the length to be constant. Checkout the CSS  
Viewer plugin for Firefox, it is awesome. You just point at the field  
and it shows a floating window shows you which css elements define it.
