Drupal 7 email fields

Submitted by bas on Tue, 17/12/2013 - 11:20

Sometimes the small tips are the nicest. If you own a smartphone or tablet it can be annoying to enter an email address in a regular textfield. If you fill out a form and select the email field you expect an virtual keyboard layout suited for filling in email addresses, not your default keyboard layout. The simple trick to get this field to behave is to use the HTML5 <input type="email" /> tag. Now the default Drupal 7 Form API only supports regular text inputs. Changing existing forms is actually quite easy, albeit a bit weighty. It only required 2 steps:

  1. install and enable the elements module
  2. write a hook_form_alter() in your custom theme or module to alter the #type property of the form element. (ie, change textfield to emailfield)
Here's an example:
/**
 * Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // I hate simplenews but it makes a good example
  if ($form_id == 'simplenews_block_form') {
    $form['mail']['#type'] = 'emailfield';
  }
}

"Isn't installing the elements module just to change 1 field a bit weighty?" you might ask. Yes, it is quite a hefty solution to a very slim problem. But I believe the elements module offers a universal way forward when extending the default D7 form API. And it seems like it's pretty future proof because it is included in D8 core. So we might as well start using it now.

Comments

Submitted by School Assignments (not verified) on Wed, 16/05/2018 - 10:40

help me write my paper write my paper cheap application letters [url=https://domypaper.us.com]sites that write papers for you[/url]

Submitted by probiotic (not verified) on Wed, 16/05/2018 - 10:49

gundry md dark spot diminisher lectins foods high in lectin [url=https://lectins.us.com]lectin in tomatoes[/url]

Submitted by Custom Essays (not verified) on Wed, 16/05/2018 - 11:14

vocabulary for writing essays college essay help write my essays [url=https://writemyessayonline.us.com]write an essay online[/url]

Submitted by lectins to avoid (not verified) on Wed, 16/05/2018 - 11:27

steven gundry probiotics polyphenols in tea [url=https://probiotics.us.com]probiotics for women[/url]

Submitted by Payday (not verified) on Wed, 16/05/2018 - 11:36

bad credit installment loans guaranteed money till payday guaranteed loans [url=https://badcreditloansguaranteedapproval.us.org]bad credit loans guaranteed approval[/url]

Submitted by My Essay Writing (not verified) on Wed, 16/05/2018 - 11:45

write a paper write my custom paper writing an article review [url=https://domypaper.us.com]do my paper[/url]

Submitted by Direct Lenders (not verified) on Wed, 16/05/2018 - 11:49

installment loans installment loans installment loans [url=https://installment-loans.us.com]installment loans no credit check[/url]

Submitted by Quick Loan (not verified) on Wed, 16/05/2018 - 12:04

poor credit loans small loans with monthly payments no credit loans [url=https://credit-loans.us.com]school loans[/url]

Submitted by Write My Essay ... (not verified) on Wed, 16/05/2018 - 12:09

essay jedi writing an essay writing comparison and contrast essays [url=https://anessay.us.com]college essay consultant[/url]

Submitted by usaa car insurance (not verified) on Wed, 16/05/2018 - 12:20

extremely cheap auto insurance compare car insurance quotes cheap auto insurance quotes [url=https://cheapautoinsurancequotes.us.com]cheap auto insurance quotes[/url]

Submitted by cheap auto insu... (not verified) on Wed, 16/05/2018 - 12:22

comprehensive car insurance comparison what is gap insurance for cars cheap car insurance in georgia [url=https://cheapautoinsurancequotes.us.com]car insurance rates[/url]

Submitted by insurance quote (not verified) on Wed, 16/05/2018 - 12:35

aarp insurance auto auto insurance florida auto insurance [url=https://auto-insurance.us.com]auto insurance florida[/url]

Submitted by Instant Online ... (not verified) on Wed, 16/05/2018 - 12:35

quick loans no credit no faxing payday loan awl loans [url=https://credit-loans.us.com]credit loans[/url]

Submitted by Loans Online (not verified) on Wed, 16/05/2018 - 12:35

loans guaranteed approval guaranteed loans bad credit loans guaranteed approval [url=https://badcreditloansguaranteedapproval.us.org]payday loans topeka ks[/url]

Submitted by lectins (not verified) on Wed, 16/05/2018 - 12:50

foods with polyphenols list foods high in polyphenols list foods high in polyphenols [url=https://polyphenolsfoods.us.com]polyphenol rich foods[/url]

Submitted by Speedy Cash (not verified) on Wed, 16/05/2018 - 13:10

installment loans installment loans for bad credit installment loans [url=https://installment-loans.us.com]installment loans[/url]

Submitted by Dog Ate Homework (not verified) on Wed, 16/05/2018 - 13:21

problem solving problem solving assignment assignment problem solver [url=https://problemsolving.us.com]creative thinking[/url]

Submitted by Payday Express (not verified) on Wed, 16/05/2018 - 13:38

loan interest rates online installment loans for bad credit personal loans low interest rates [url=https://loaninterestrates.us.com]personal loans low interest rates[/url]

Submitted by Loans Online (not verified) on Wed, 16/05/2018 - 14:13

guaranteed bad credit loans installment loans bad credit installment loans [url=https://installment-loans.us.com]quick payday loans[/url]

Submitted by direct car insu... (not verified) on Wed, 16/05/2018 - 14:13

triple aaa car insurance best car insurance companies best auto insurance [url=https://bestinsurance.us.org]usaa auto insurance[/url]

Submitted by Loan Cash (not verified) on Wed, 16/05/2018 - 14:22

payday advance fast cash advance payday loan payday advance loans [url=https://payday-advance.us.com]payday advance[/url]

Submitted by Easy Payday Loan (not verified) on Wed, 16/05/2018 - 14:41

credit loans credit loans guaranteed approval credit loans [url=https://credit-loans.us.com]quick loans no credit[/url]

Submitted by Money Loan (not verified) on Wed, 16/05/2018 - 14:55

fast cash advance payday loan payday advance payday advance [url=https://payday-advance.us.com]payday advance[/url]

Submitted by Paydayloan (not verified) on Wed, 16/05/2018 - 14:58

cash loans with monthly payments credit loans bad credit loan [url=https://credit-loans.us.com]credit loans[/url]

Submitted by Spotloan (not verified) on Wed, 16/05/2018 - 15:19

personal loans for poor credit personal loans for bad credit small personal loans with bad credit [url=https://personalloansforbadcredit.us.org]personal loans for bad credit[/url]

Submitted by Speedy Cash (not verified) on Wed, 16/05/2018 - 15:32

loans with bad credit loans with bad credit quick personal loans [url=https://loanswithbadcredit.us.com]get a loan with bad credit[/url]

Submitted by metabolism boosters (not verified) on Wed, 16/05/2018 - 15:35

polyphenols food polyphenols foods foods with polyphenols list [url=https://polyphenolsfoods.us.com]polyphenols food[/url]

Submitted by foods with lectins (not verified) on Wed, 16/05/2018 - 15:40

polyphenol rich foods gundry superfood superfood [url=https://polyphenolsfoods.us.com]polyphenols food[/url]

Submitted by Loan Cash (not verified) on Wed, 16/05/2018 - 16:04

loan interest rates loan interest rates fast cash 500 [url=https://loaninterestrates.us.com]loan interest rates[/url]

Submitted by insurance quotes (not verified) on Wed, 16/05/2018 - 16:27

goautoinsurance car insurance florida car insurance quotes [url=https://comparecarinsurance2018.us.com]compare multiple auto insurance quotes[/url]

Submitted by Paper Writer (not verified) on Wed, 16/05/2018 - 16:27

write my paper spacebattles creative writing do my paper [url=https://domypaper.us.com]writing my paper[/url]

Submitted by dr grundy (not verified) on Wed, 16/05/2018 - 16:56

foods high in polyphenols without lectins polyphenols foods list polyphenols foods [url=https://polyphenolsfoods.us.com]polyphenols food[/url]

Submitted by Cash Loan (not verified) on Wed, 16/05/2018 - 16:56

payday loans direct lenders need payday loan loan interest rates [url=https://loaninterestrates.us.com]loan interest rates[/url]

Submitted by Payday (not verified) on Wed, 16/05/2018 - 17:17

credit loans credit loans cash advance america scam [url=https://credit-loans.us.com]payday loans in california[/url]

Submitted by allstate insurance (not verified) on Wed, 16/05/2018 - 17:24

best insurance best insurance best insurance [url=https://bestinsurance.us.org]best insurance[/url]

Submitted by Paper Back Writer (not verified) on Wed, 16/05/2018 - 17:26

economics homework solver need help with my homework physics homework solver [url=https://domyhomework.us.com]do my excel homework[/url]

Submitted by dr steven gundr... (not verified) on Wed, 16/05/2018 - 17:26

dr gundry supplements probiotic supplement probiotic supplement [url=https://probiotic.us.com]steven gundry[/url]

Submitted by Pay Day Loans (not verified) on Wed, 16/05/2018 - 17:36

guaranteed loans guaranteed loans installment loans guaranteed [url=https://badcreditloansguaranteedapproval.us.org]weekend payday loans[/url]

Submitted by allstate claims (not verified) on Wed, 16/05/2018 - 17:48

car insurance calculator compare car insurance compare car insurance [url=https://comparecarinsurance2018.us.com]compare car insurance quotes[/url]

Submitted by Buy Essays Online (not verified) on Wed, 16/05/2018 - 17:54

math help online algebra help algebra help [url=https://algebrahelp.us.com]do your math homework for you[/url]

Submitted by erie car insurance (not verified) on Wed, 16/05/2018 - 18:05

car insurance quotes online car insurance quotes car insurance quotes online [url=https://carinsurancequotesonline.us.com]classic car insurance[/url]

Submitted by dr gundry foods... (not verified) on Wed, 16/05/2018 - 19:02

probiotics foods containing polyphenols probiotics benefits [url=https://probiotics.us.com]antioxidant vitamins[/url]

Submitted by Online Payday Loans (not verified) on Wed, 16/05/2018 - 19:09

personal loans low interest personal loans low interest rates personal loans with low interest rates [url=https://loaninterestrates.us.com]loan interest rates[/url]

Submitted by Essay-writer.Org (not verified) on Wed, 16/05/2018 - 19:29

algebra homework solver assignment problem solver creativity problem solving [url=https://problemsolving.us.com]problem solving[/url]

Submitted by prebiotic food list (not verified) on Wed, 16/05/2018 - 19:53

dr steven gundry polyphenols food foods that contain polyphenols [url=https://probiotics.us.com]probiotics[/url]

Submitted by Online Payday Loans (not verified) on Wed, 16/05/2018 - 19:53

loan interest rates personal loans low interest rates loan interest rates [url=https://loaninterestrates.us.com]personal loans with low interest[/url]

Submitted by Online Payday Loans (not verified) on Wed, 16/05/2018 - 20:44

loans consolidation personal loans for bad credit payday advance locations [url=https://personalloansforbadcredit.us.org]personal loans for bad credit[/url]

Submitted by boost your meta... (not verified) on Wed, 16/05/2018 - 21:12

gundry supplements bloated stomach causes gundry supplements [url=https://polyphenols.us.com]chronic fatigue syndrome[/url]

Submitted by BillyBig (not verified) on Wed, 16/05/2018 - 21:21

wh0cd558056 [url=http://levitra.college/]cheep lavitra for sale[/url]

Submitted by prebiotic fiber (not verified) on Wed, 16/05/2018 - 21:59

metabolism boosters smoother digestion foods high in polyphenols [url=https://polyphenolsfoods.us.com]foods high in polyphenols[/url]

Pages

Add new comment