0

I created custom block for my entity and I want to add this entity creation form to the 2nd sidebar. I managed to do this and this is how it looks like now:

enter image description here

First textfield goes out of bounds, where as second one, which is textarea type, is okay. After looking at Form API, I realized that textarea is re-sizable and textfield is not. How can I solve this? If I put title as text area it doesn't look that nice so I would be very happy if I could stick to textfield and make it fit somehow?

2 Answers 2

1

You can use the #size attribute if you are creating the field from hook_form function in custom module.Below is the example

$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,
  );

or you can do the css, using the field selector and then applying "width:in px"

1

enter image description hereYou can change field size .Default size is 60.You can text field width by css. enter image description here

5
  • Thank you for a fast answer, may I ask where did you find this form for text processing?
    – Viktor
    Commented Oct 21, 2016 at 7:51
  • Are you create text field custom or by ui ? If you done this by ui then when you edit this field then this settings show Commented Oct 21, 2016 at 7:56
  • Can you Please Vote my answer . Commented Oct 21, 2016 at 7:59
  • By custom, not by ui
    – Viktor
    Commented Oct 21, 2016 at 8:08
  • Read this and change your field size api.drupal.org/api/drupal/… Commented Oct 21, 2016 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.