Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello
I'm trying to change the size of a telephone field on a content type form alter function
Following attempts doesn't seems to work
$form['field_my_telephone']['#size'] = 10;
$form['field_my_telephone']['und']['#size'] = 10;
$form['field_my_telephone']['und'][0]['#size'] = 10;
I've seen this post, but it's related to 8.x and not 7.x (https://www.drupal.org/project/drupal/issues/2527990)
Please any suggestions are welcome
Comments
Comment #2
gisleIt depends on the theme. For Bartik and most themes, this is the way to control the size of a textfield widget – including phonefield – is:
However, if your theme is Bootstrap or a subtheme thereof, this has no effect. Bootstrap, by default, increases the size of an input to the full width of the container.
When Bootstrap is used as the theme, you must use css to control the size of a textfield. Example:
By the way: This is the case for all Drupal 7 textfield widgets.
The post you link to is about a the Drupal 8 core Telephone module (it does not share any code with this module).
I hope this fixes the issue. Please review.
Comment #3
gusantor CreditAttribution: gusantor commented@gisle Thank you
Using a sub theme of bartik
I'll try css soon
Comment #4
gisleNo feedback in three months. Assuming it means it is fixed. You have two weeks to reopen if it is not.