Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
I want to have a form textfield automatically uppercase the text entered as it is typed in. I was hoping that there was as set-able property that would allow for this but I’m unable to find one.
$form['elementName'] = array(
'#type' => 'textfield',
'#title' => $this->t('Address'),...
The searches I have done so far point to the use of ‘Plugins.’ However if there is a simple(er) solution I prefer that. Any ideas appreciated;
96.1k1515 gold badges157157 silver badges283283 bronze badges
asked Mar 2, 2016 at 15:54
51766 silver badges1616 bronze badges
However if there is a simple(er) solution I prefer that.
Sorry, maybe I going too deep, but the most simpler solution that you can use just for display is a CSS solution.
Based in your example:
That's it, any char will be uppercase in your textfield. If need store in uppercase, just change case before save.
answered Mar 2, 2016 at 18:16
2,4931313 silver badges2020 bronze badges
The easy solution would be to do this in a submit handler before the value is actually saved.
If this is for display purpose - the Drupal way is to not alter what is saved, but alter how it appear on screen.
answered Mar 2, 2016 at 15:59
35.3k1010 gold badges6767 silver badges107107 bronze badges