Why isn't the form text field respecting the length I set?

$form['value'] = array(
    '#type' => 'textfield',
    '#title' => t('Value'),
    '#size' => 3,
    '#maxlength' => 3,
'#required' => TRUE,
    '#description' => t('1-100'), );

Yet when I display that the field extends the width of the form...not just 3 characters.

Comments

tmj2k7’s picture

how would I get several such fields (when sized 3 properly) to display side by side so it doesnt extend all the way down the page?

www.thelinuxuser.com

drupal777’s picture

tmj2k7’s picture

Icky. That feature isn't worth me hacking around forms.inc right now. I would like the field sized properly however.
www.thelinuxuser.com

drupal777’s picture

It works fine on my machine, so I'm sorry but I don't know anything to suggest.

khoogheem’s picture

I have noticed that some Themes will override your size for textfields and other fields that allow a size and throw it to 100% of the size of the window.

Try using another theme and see if you have the same problem. I know when using spreadfirefox on one of my sites this is what happens, and if I go back to another theme the fields are displayed correctly.

tmj2k7’s picture

my theme is custom from scratch. let me find the css selector for textfields and see if I can override it.

www.thelinuxuser.com

tmj2k7’s picture

its gotta be a theme/div/css thing. cut n past of the underlying html unstyled and its fine.
www.thelinuxuser.com

jcastr1’s picture

found it! Inside drupal.css (4.7 build)

drupal.css


.node-form .form-text {
  display: block;
  /*remove or set the following line to the value you want*/
  /*width: 95%; */
}

this was bugging me for a while now, hope it helps others building custom forms.