Hi
Note: Please forward to the most appropriate project.
Set #size for type textfield to be 3 characters wide, but this attribute is ignored and textfield spans width of browser:
$form['level_of_effort'] = array(
'#type' => 'textfield',
'#title' => t('Level of Effort'),
'#description' => t('Level of Effort value must be between 0 and 100.'),
'#size' => 3,
'#maxlength' => 3,
);
What does work is #maxlength which does limits the number of characters within textfield.
Ideas what I may be doing wrong?
Thanks
Jeff in Seattle
Comments
Comment #1
litwol commentedPlease stop asking drupal core related questions on this project.
Information you may be most interested in is:
Form API reference: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6
Form API quickstart: http://api.drupal.org/api/file/developer/topics/forms_api.html/6
Good luck.
Comment #2
jennifer.chang commentedconfirmed.
Comment #3
jennifer.chang commentedComment #4
nevets commentedA lot of theme use CSS to set the field length. Try using the Firefox extension firebug to determine the css and change so it uses auto for the width.
Comment #5
Anonymous (not verified) commentedI'm having a problem like this with one Form API element, I wonder if it is caused by the same thing.
The form element is defined in its own function. That function is called to attach it to the Field configuration form. The same function is also called to attach it to a form defined in my module.
When the textfield is attached to the Field config form, the '#size' attribute is applied. When the textfield is attached to the custom form, the '#size' attribute is ignored.
Comment #6
Anonymous (not verified) commentedMy issue had to do with vertical tabs. There is a style in vertical tabs
This overrides the size attribute on a textfield.
Comment #7
sunThanks for taking the time to report this issue.
However, marking as duplicate of #970426: Regression: Vertical Tabs styling on input elements overrides specifically set FAPI keys. You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.
Comment #8
bartes commented$form['start']=array(
'#type'=>'textfield',
'#title'=>t('test),
'#description'=>t('(Veld verkleinen)'),
'#attributes' => array('maxlength' => 4, 'size' => 4),
'#default_value' => t('1234'),
);
Comment #9
nevets commentedOther than posting code, you do not say why you are posting. If it is about 'size', there is css that may change the visual size.