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 Charles (not verified) on Mon, 05/01/2015 - 04:45

Was searching for something to explain how the Elements module types worked for ages, thanks for this

Submitted by bas on Tue, 10/02/2015 - 07:48
bas's picture

You're welcome

Submitted by Anonymous (not verified) on Wed, 20/05/2015 - 19:02

Wooow, thanks a lot, I spent hours to figure out how to change the input type to email. :)

Submitted by bas on Fri, 22/05/2015 - 01:43
bas's picture

Glad that helped you out. Thanks for leaving a note.

Submitted by Alexis (not verified) on Tue, 13/10/2015 - 09:46

Thanks !

I have installed elements module and then,
it works with this code :

$form['mail']['#type'] = 'emailfield';

Submitted by bas on Wed, 14/10/2015 - 12:04
bas's picture

Oh, thanks, I see there's a small mistake in my original post. I omitted ['#type']. Cheers Alexis

Submitted by DreamingX (not verified) on Wed, 13/01/2016 - 00:50

form alter should return $form...

Submitted by bas on Wed, 13/01/2016 - 23:22
bas's picture

Passed by reference instead. Thanks for the note.

Submitted by Georgesib (not verified) on Fri, 27/04/2018 - 07:12

Apoteket Viagra Pris
The Net is constantly altering, therefore you ought to consistently alter the methods you make use of it to market your products. To do that, you should be likely to keep track of new marketing and advertising guidelines. Here are a few wonderful items of advice that can help give your aged Online marketing strategies an enhancement.
Clomiphene Citrate Online Uk
Understand what a payday loan is. A pay day loan can be a high-curiosity financial loan to get a short time period of time. They are normally done with one trip to the payday advance business office. To acquire virtually immediate money, you must write out a check out towards the pay day loan company for the need for the money, as well as the curiosity costs, as well as any service fees. The lender cashes this examine at some arranged-upon long term day, typically one, or 2 weeks.
Viagra Cialis Ireland
Attire properly when you go upon an job interview. The best advice would be to 'dress as being a boss'. Get in clothed like you will be the employer of the individual from the place you would like. This may be a easy way to remain apart from the package in virtually any job interview establishing, and teaches you are interested in the task.
Buy Testosterone Enanthate Powder Uk

Submitted by Guestsnics (not verified) on Fri, 27/04/2018 - 11:38

Submitted by RichardBag (not verified) on Sun, 29/04/2018 - 08:24

Abercrombie And Fitch Jeans Uk
When you read at the start of this short article, lower back pain is an issue that a great many men and women experience due to way we reside. Adhering to these effortless suggestions can assist you to remedy this common and incapacitating problem in your daily life. Consider many of these recommendations now to begin sensing greater!Read More About Improving Your Diet Good quality In this article!
http://www.vegetarianrestaurantbyhakin.com/nike-air-uptempo-pippen-relea...
One of the most vital points that you will have to accomplish is to adhere to your price range while you are marrying each other. You will have a lots of enticement to spend significant amounts of funds, but need to recognize your financial limitations to prevent engaging in a hole.
Hogan Rebel Price
Plaything around with taking photos in nature. Consider photos of your landscape, setting sun, attractions, creatures, and even more. Consider exciting shots to see what photo gems you think of. The outdoors supplies a lot of wonderful and beautiful moments. Try out going on a character walk with the digicam several times, and acquire photographs to create a portfolio from.
http://www.miamihispanicballet.com/prada-shoes-for-men-price-142.html
Do not cut corners with regards to the quality of building components for redesigning or maybe you could pay for it later on. Acquiring cheap wood, plastic-type material or appliances with dings and dings and dents, will decrease the original cost of a project but devalue the whole property afterwards. Given that your property is a long term purchase, create and repair with high quality components, whether or not for reselling worth or even your individual profession from it.
Nike Air Force 180
When you use your apple ipad tablet, you could really feel as though you're constrained as a result of lack of knowledge. You must keep reading this short article to be able to far better realize how to use your apple ipad tablet for additional of your respective daily duties. You can find programs for every thing! You need to simply find out information and facts as to how to use your apple ipad.
http://www.marionnettesdangouleme.fr/706-nike-roshe-run-femme-custom.php
Show the way you use your product on video clip. This is often a fantastic way to demonstrate your prospects the way that they are likely to expertise your merchandise. Both produce a video and go comprehensive, or consider having a audio track within sheer demonstration. This will help people really feel more confident about purchasing from you.
Nike Lunarlon Pink And Grey
Make sure you keep the weblog eye-catching and readable with very good pictures and drawings and simple, fascinating blogposts. Prevent lengthy, rambling articles that take up a lot of your readers' time. Make your articles or content to 3-or-four-hundred or so words and phrases every. This may make your website followers coming back for much more.
Nike Lebron Xii
Should you suffer from zits, you might want to try to eliminate dairy products from your diet program for a time period of 30 days. You could be possessing allergy symptoms to dairy food. Have a record for your calendar month that may be acne breakouts distinct. As soon as the 30 days is over, begin adding dairy foods for your diet regime one-by-one. If you see that particular goods lead to more break outs, maybe you have identified you might be sensitive to this merchandise.

Submitted by Cornelius (not verified) on Fri, 08/06/2018 - 18:59

icd 10 uri cephalexin for sinus infection
mortin effexor 75 mg
Hi there to every single one, it's really a pleasant for me to pay a visit this site, it contains precious Information. prozac vs zoloft

Submitted by Alpha TRT (not verified) on Sat, 09/06/2018 - 07:34

I quite like reading through an article that can make men and women think.
Also, many thanks for permitting me to comment! http://www.dimensioneautobacoli.com/modules.php?name=Your_Account&op=use...

Submitted by Curtistep (not verified) on Tue, 01/05/2018 - 05:12

Air Max 2016 Colori
Some of the most amazing, intimate holiday destinations have been in areas prone to disasters. A number of calamities are seasonal - later summertime and tumble are hurricane period in the Caribbean, for example. Tourists going for places which might be susceptible to holiday problems should be aware of this fact, in the event they wind up inside an evacuation scenario.
http://www.bimars.it/nike-2016-air-max-203.htm
As mentioned initially on this write-up, there are numerous types of skin. Fortunately, in addition there are just as different ways to further improve, protect, and maintenance the complete health and look of the epidermis. Regardless if you are handling your experience or physique, you will see that reading this write-up was a step in the best course.Keeping All Of Your Jewelry In Great Design
Nike Sb Janoski Red Earth
Examine simple bookkeeping. To be an excellent investor, you'll require to be able to fully grasp annually-conclusion record and stick to a stock exchange record. Fundamental data processing abilities needs to be sufficient that will help you go through these kinds of records. You don't need an accounting diploma as a trader, but you will require some training.
http://www.velvetyogurt.com/026-fendi-karlito-purse.html
The most famous colours at present for garments are light colours. Specifically, peppermint natural is building a huge comeback this coming year. So, if you are into keeping up with the most recent variations, purchase a nice peppermint environmentally friendly outfit, kind of pumps, tote and employ natural make-up and nail polish.
Nike Air Max 1 Essential Black Light Bone White
When you will the interview, the reason you obtained the job interview is most likely due to the referrals that you had on your continue. Your personal references will be the answer to having your foot inside the doorway for almost any job interview. Find some great trainers, peers or earlier supervisors who you can use as personal references. You typically want to request their permission in advance because most likely they are contacted.
http://www.cuasquias.com/nike-roshe-run-slip-on-black-white-095.htm
To actually get the most out of a commercial property investment, don't only think about condominiums. There are actually numerous types of professional qualities to get, from offices to trailer recreational areas, and it's advisable to look at a great deal of options so that you can obtain the best deal accessible.
New Balance 1600 Daytona
Utilize mascara till you reach the ideal look for your eyelashes. You could stay away from doing this due to a clumpy or unnatural appearance. Nonetheless, you can make your eyelashes look much longer with mascara that does not look overdone. When you get the required appearance you would like try to different your lashes with a tool and will also take away any clumpiness.
Nike Roshe Run Damen Grau Orange
A good thing for unskilled traders to do is to use a stock dealer to setup the most effective profile for his or her specific needs. A broker can manual the brand new investor to more secure investments, in order to avoid loss in their purchase funds. Look at brokerage service companies to compare costs and benefits.

Submitted by Angelmex (not verified) on Wed, 02/05/2018 - 01:30

Testosterone Steroid Use
Make use of a satin pillowcase in your your bed. 100 % cotton includes might be difficult in your hair, resulting in problems, hair thinning and various other difficulties. Not only will silk pillowcases be delicate on your hair follicles, you will additionally take advantage of the convenience resting on an easy and gentle area during the night.
Nandrolone Decanoate Sale
You have to be respectful of the roommate's hopes. You should learn how to assist them so that it tends to make your time and efforts much easier. Sit down when you arrive at institution and see the things you both count on out from a roommate so you can each be happy.
Drostanolone South Africa
Although the sunlight IS great for our health and wellbeing, supplying us the ability to produce Nutritional D, it could be terribly damaging to our epidermis. Sunlight shoots out various forms of rays which can virtually damage the outer and internal levels of skin area, offering an launching for acne to take above. Stay out of direct sunlight to help keep acne breakouts aside.
Tadalafil Powder Buy

Submitted by Direct Lenders (not verified) on Thu, 03/05/2018 - 02:26

payday loan online i need money fast bad credit payday loans rapid payday loans

Submitted by Paydayloan (not verified) on Thu, 03/05/2018 - 08:15

bad credit payday loans payday loan online pay day pay day

Submitted by VictorReose (not verified) on Thu, 03/05/2018 - 09:59

Cialis 20mg Effets
Should you be having a image of an issue that is small compared to you, such as a family pet or a little one, get upon their levels. This way the angle won't affect the design of the picture. This may develop a far more private and inviting photo that folks will enjoy.
Primobolan Manufacturer
Include solar power light-weight pipes to your property. This can be a 3 component system that may give dim rooms use of normal sunlight. This may create your bedrooms more desirable, and save a little money more than having to consistently use electrical energy to gentle your room. These are listed minimally and relatively easy to setup.
Testosterone Online Uk
Consume meals that happen to be crisp and organization. Meals like this will help to clean your pearly whites. An apple is an excellent instance which is often known as, the toothbrush of mother nature. You may also try to eat meals like popcorn, green beans and celery. These needs to be the last meals consume with your meal, in the event you can't clean your the teeth afterwards.
Kigtropin Hgh Price In India

Submitted by Payday Loans Online (not verified) on Thu, 03/05/2018 - 16:54

payday loans no credit check payday loans pay day loan payday loans

Submitted by ThomasDaync (not verified) on Thu, 03/05/2018 - 18:05

Air Jordan Retro 5
Be great to your consumers. Many people are excellent to deal with, however, you will certainly run across a miserable shopper, who is rude for you. Know that it isn't worth your time and energy to dispute or even to title-call. Managing rude individuals with goodness generally calms them downward and apart from, you don't have the time to get into combats, anyways. You have a business to operate.
http://www.ultimolog.com/709-puma-shoes-women-blue.php
Prevent retaining junk in the home for long. It can be frequent for folks to want permit the trash can load just before emptying. However, if you have thrown away food items and food items product packaging, you create an setting that draws pest infestations. Work with a lidded can and acquire your trash out one or more times every day.
Nike Zoom Clear Out Red And White
Since you now have some helpful suggestions, it is possible to start using a lot more great photographs. Using this type of understanding plus some determination to help make some effortless alterations in your capturing strategies along with your camera, you can find some rather incredible photographs from the camera that you will be utilizing.Think Slim And Begin Losing Weight Today
http://www.harmonyconcept.fr/nike-air-max-tavas-custom-403.php
To successfully decide on a proper visa or mastercard based on your expections, determine what you would like to make use of your charge card rewards for. Many credit cards offer you diverse advantages courses for example the ones that give savings on journey, food, gasoline or gadgets so decide on a card you like very best!
Adidas Superstar Sale Womens
As mentioned at first with this article, no one is exempt from developing and struggling with allergic reaction. Nonetheless, using the proper suggestions, allergic reactions are something which can be operated. Take advantage of the guidance which has been offered to you in this post, and you will shortly view your allergy symptoms operated.Fantastic Manual On How To Eliminate Obstructive Sleep Apnea
http://www.agora-entreprise.com/362-oakley-airdrop.php
In terms of applying for a credit card, make sure that you know what the once-a-year portion rates are on your deal. This is important, because the APR can tremendously outcome your capability to spend your harmony off. Having a high APR will find yourself priced at you plenty more income in the future, unless you pay back your stability easily.
Nike Shoes Womens Running
You need a excellent grin, so you should have it. Don't undermine with dull, stained pearly whites. There are several strategies on the market nowadays that will help you reach your primary goal of any beautiful laugh and shiny white teeth. Read this report for more information about the different ways that you could lighten your pearly whites.
Nike Air Max 1 Schwarz
To have a great camping out getaway with kids, try to think about activities that may keep these entertained. You can play online games, sing out around the flame, go swimming, hike, canoe, go boating, go bike riding or perhaps allow them to have a video camera to consider photos. In case your children are entertained, they will probably benefit from the encounter and would like to go camping out yet again.

Submitted by Eugenerek (not verified) on Fri, 04/05/2018 - 11:32

Air Max Tavas
Whether you are searching for key expense results or small risk, all of the guidance herein, may help you obtain your targets. Investing can be quite a bumpy street, but having a certain amount of knowledge accessible will make sure that you conditions all the gradual occasions and profit whenever possible from the wonderful occasions.Straightforward Approaches On How To Approach Allergy symptoms
http://www.vin-jumert-41.com/dsquared2-womens-high-top-sneakers-400.php
Consider eating more garlic clove. Adding a little bit more garlic clove to your diet is capable of doing magic if you suffer from yeast infections. Studies have found out that garlic cloves is able to kill off of candida. This enables you to get rid of candidiasis and may even avoid them from reoccurring down the road.
Adidas Trainers Mens Samba Sky Blue Yellow
Precious jewelry that is made with milky, iridescent, and stylish opals, takes a light-weight feel in relation to cleansing. Usually do not reveal the stones to warm water, vapor, or ultrasonic cleaning solutions, as intense temperature can certainly harm the surface of the rock. Alternatively, bands, pendants, and bracelets that come with opals, ought to be cleaned out with a soft cloth after a short saturate in amazing drinking water.
http://www.shakiraisabel.com/860-nike-windrunner-black-and-white-womens....
It's vital that you understand that there's more that is put into blogging that meets the eye. With a little luck,these guidelines have drop some light-weight about the subject. Whilst it's not just a very difficult subject matter, it really is continue to an extremely comprehensive one particular. Begin using these suggestions to help you get started on the right course.Wonderful Tips And Advice To The Forgetful
Burberry Shoes Amazon
If you get rid of a web page from your internet site, really take it off! Utilizing a 301 redirect is great, but search engines like google can still get the initial page through hyperlinks with it on other websites as well as by yourself website. Erase all outdated documents from your web server when they're no longer essential.
http://www.internalbranding.it/646-nike-air-max-2015-prezzo.htm
Be sure you scrub your face a minimum of 2 periods each day. This will ensure you don't possess any microorganisms on the face. Ensure you aren't too rough when cleaning. If you see your skin is becoming annoyed from laundry too much, scale back how often you are doing it.
Nike Cortez Shoes Gang Related
Outdoor camping trips with the family end up being the thoughts of legend. Occasionally these thoughts are perfect, at times these are terrible. To provide your next outdoor camping vacation the highest likelihood of achievement, implement all the tips you have go through in this post. They may serve as the tent of knowledge that shields you.Great Tips That Will Help Stop You From Aging
Jordan 11 Space Jam Low
When buying an auto, you would like it to be a very good practical experience. This could be tough when the salesperson who you are working with has been also pushy. If you realise on your own dealing with a person who rubs you the improper way, try to find another salesman or location to buy a vehicle.

Submitted by Cash Loan (not verified) on Sat, 05/05/2018 - 02:58

payday loans no credit check pay day bad credit payday loans loan term

Submitted by Direct Lender Loans (not verified) on Sat, 05/05/2018 - 08:05

payday loans no credit check same day online loans payday loans without checks bad credit payday advance

Submitted by Spotloan (not verified) on Sat, 05/05/2018 - 23:35

payday loans guaranteed payday loans pay day loan https://loansfor.cars - california payday loan

Submitted by Loan Cash (not verified) on Sun, 06/05/2018 - 23:22

need money today pay day pay day payday loans

Submitted by Instant Online ... (not verified) on Tue, 08/05/2018 - 00:17

payday loans for bad credit guaranteed online loans no employment verification payday loan pay day loans

Submitted by LionelDiz (not verified) on Wed, 09/05/2018 - 13:52

Buy Stanozolol Nz
To indulge the skin and look after it effectively, avoid wearing small garments for long amounts of time. Tight clothes rub and chafe the facial skin, irritating it. In warm weather, binding garments trap perspire on the skin, offering far more tenderness and stimulating germs growth. For far healthier pores and skin, use loose apparel, specially in the hotter summer season.
Cialis Apotek
Many instructors will inform you to modify your exercise routine each and every month or two. You ought to even so understand that this may not be essential. If the schedule that you are currently using is offering superb outcomes, then you certainly must keep it going! Alter your routine only should it be not offering you the final results which you seek out, or if you feel you may have gained many of the benefits from it.
Trenbolone Canada
Stay away from carbohydrate food when you are attempting to lose weight. Carbs are low-cost and scrumptious, although not actually healthier or nourishing. It takes this enzymatic process a long time to method carbohydrates, such a long time that a great deal of the potential electricity in carbs-rich meals are transformed directly into extra fat instead of getting burned usefully.
Buy Methenolone Acetate

Submitted by accurate automotive (not verified) on Wed, 09/05/2018 - 15:59

car insurance quotes car insurance quote online usaa auto insurance [url=https://carinsurancequotesonline.us.com]get multiple auto insurance quotes[/url]

Submitted by Speedycash (not verified) on Wed, 09/05/2018 - 16:03

fast cash loans with no credit check installment payments cash loan [url=https://moneyfast.us.com]money fast[/url]

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

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

Submitted by safe auto insurance (not verified) on Wed, 09/05/2018 - 17:16

top car insurance companies inexpensive auto insurance compare car insurance [url=https://comparecarinsurance2018.us.com]compare multiple auto insurance quotes[/url]

Submitted by rental car insu... (not verified) on Wed, 09/05/2018 - 17:48

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

Submitted by Bad Credit (not verified) on Wed, 09/05/2018 - 18:11

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

Submitted by Personal Loans (not verified) on Wed, 09/05/2018 - 18:32

emergency loans no credit check payday loans no credit check payday loans no credit check [url=https://paydayloansnocreditcheck.us.org]payday loans no credit check same day[/url]

Submitted by Pay Day Loans (not verified) on Wed, 09/05/2018 - 18:39

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

Submitted by Buy An Essay (not verified) on Wed, 09/05/2018 - 19:05

write my essay write my essay online essay writing book free download [url=https://writemyessayonline.us.com]do my essay[/url]

Submitted by Payday Loan (not verified) on Wed, 09/05/2018 - 20:05

installment loans no credit check loans in an hour installment loans [url=https://installment-loans.us.com]loan places near me[/url]

Submitted by Write College Essay (not verified) on Wed, 09/05/2018 - 20:18

solve assignment problem online solve assignment problem solve assignment problem [url=https://problemsolving.us.com]statistics homework solver[/url]

Submitted by Paper Back Writer (not verified) on Wed, 09/05/2018 - 20:53

writing assignment assignment help writing assignments [url=https://assignmenthelp.us.com]assignment help experts[/url]

Submitted by Loan (not verified) on Wed, 09/05/2018 - 21:01

bad credit loan credit loans credit loans [url=https://credit-loans.us.com]payday loans illinois[/url]

Submitted by Good Homework Music (not verified) on Wed, 09/05/2018 - 21:22

buy online essays write a essay website to write essays [url=https://anessay.us.com]key to writing a good essay[/url]

Submitted by affordable insu... (not verified) on Wed, 09/05/2018 - 21:36

best insurance best auto insurance companies 2018 best cheapest car insurance companies [url=https://bestinsurance.us.org]best cheapest car insurance companies[/url]

Submitted by nationwide insu... (not verified) on Wed, 09/05/2018 - 21:49

www.geico.com auto insurance car insurance rates best insurance [url=https://bestinsurance.us.org]best auto insurance companies[/url]

Submitted by Loans (not verified) on Wed, 09/05/2018 - 21:51

how to take out a loan online installment loans for bad credit online payday loans no credit check [url=https://paydayloansnocreditcheck.us.org]installment loans no credit check[/url]

Submitted by Buy Essays Cheap (not verified) on Wed, 09/05/2018 - 22:35

assignment writing services assignment expert assignment help [url=https://assignmenthelp.us.com]assignment expert review[/url]

Submitted by Bad Credit (not verified) on Wed, 09/05/2018 - 22:41

money quick easy installment loans online need money fast [url=https://moneyfast.us.com]need money fast[/url]

Submitted by nj auto insurance (not verified) on Wed, 09/05/2018 - 23:25

compare auto insurance quotes car insurance quotes automobile insurance quotes florida [url=https://cheapautoinsurancequotes.us.com]home and auto insurance quotes[/url]

Submitted by Buy Essay Online (not verified) on Wed, 09/05/2018 - 23:50

college homework help do my homework do my homework [url=https://domyhomework.us.com]homework help online[/url]

Submitted by Loans For Bad C... (not verified) on Thu, 10/05/2018 - 00:29

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

Submitted by Easy Payday Loan (not verified) on Thu, 10/05/2018 - 00:48

loans with bad credit small personal loans online loans with bad credit [url=https://loanswithbadcredit.us.com]personal loans with bad credit[/url]

Pages

Add new comment