Tuesday, November 30, 2010

Changing error messages in Zend Framework's Zend_Form

I was figuring a way to simply change an error message in Zend_Form specifically the Zend_Form_Element_EmailAddress because I dont like the default error message "is not a valid email address in the basic format local-part@hostname".

A simple way to do this is to use the setMessage() method of the Zend_Validate_EmailAddress. Here's my solution below:


$email = new Zend_Form_Element_Text('Email');
$email->setValidators(array(
                 array('EmailAddress', true),
               ));
$email->getValidator('EmailAddress')->setMessage('Ooops, %value% is wrong!!!', Zend_Validate_EmailAddress::INVALID_FORMAT);

In the code above, I have set the EmailAddress (Zend_Validate_EmailAddress) validator as a validator of my form's email element. In order to mess with the message, we need to retrieve the validator object by using the getValidator method of the Zend_Form_Element. From here you can access the set method setMessage and all you have to do is replace it with your new message, and target the message key which is Zend_Validate_EmailAddress::INVALID_FORMAT. Remember that setMessage overrides the default value of the INVALID constant.


Thats pretty much it!

13 comments:

Coach Factory said...

moncler outlet, cheap oakley sunglasses, canada goose outlet, oakley outlet, ugg boots, ray ban outlet, oakley sunglasses cheap, ray ban, ray ban outlet, ray-ban, oakley sunglasses outlet, oakley outlet, cheap oakley sunglasses, oakley vault, ray ban sunglasses outlet, canada goose, oakley vault, louboutin, tn pas cher, cheap oakley sunglasses, ray ban, canada goose, ray ban, ugg, oakley sunglasses outlet, ray bans, raybans, canada goose, oakley vault, ray-ban, oakley outlet, cheap sunglasses, ralph lauren, rayban, cheap oakley, moncler, oakley sunglasses cheap, gucci, oakley sunglasses outlet, moncler, oakley, canada goose, cheap sunglasses, ray bans, cheap sunglasses, oakley sunglasses cheap, moncler, canada goose outlet, rayban, discount oakley sunglasses

Coach Factory said...

jordan shoes, louboutin, michael kors outlet, michael kors, michael kors, louis vuitton handbags, nike air max, louis vuitton, gucci outlet, true religion outlet, michael kors outlet, air max, coach outlet store, ray ban sunglasses, burberry outlet online, michael kors, longchamp outlet, nike free, true religion jeans, burberry outlet online, coach factory outlet, louboutin, toms shoes, air jordan, polo ralph lauren, chanel handbags, ray ban, prada outlet, tiffany and co, nike air max, polo ralph lauren outlet, louboutin, coach outlet, nike shoes, ralph lauren, kate spade outlet, tory burch outlet, air max, oakley sunglasses, oakley sunglasses, true religion, michael kors outlet, oakley sunglasses, longchamp, prada handbags, nike free, coach purses, coach factory,

Coach Factory said...

celine handbags, chi flat iron, nike air max, nfl jerseys, ugg boots, lululemon, mcm handbags, marc jacobs, supra shoes, soccer shoes, lancel, beats by dre, vans, p90x3, ghd, herve leger, nike free, ferragamo shoes, burberry, birkin bag, juicy couture outlet, montre pas cher, soccer jerseys, ralph lauren, hermes, north face outlet, ugg boots, valentino shoes, louis vuitton, jimmy choo, new balance shoes, mulberry, rolex watches, louis vuitton, abercrombie and fitch, oakley pas cher, reebok outlet, hollister, air max, mont blanc, bottega veneta, converse shoes, ray ban pas cher, karen millen, wedding dresses, hogan, yoga pants, insanity, asics gel, timberland

co wendy said...

Sergei , October 22, 1970 Born in Christian Louboutin Bois Dore Moscow State Ozherelye. Perhaps influenced by Cheap LV Handbags their parents worship warrior army, join the army in cheap jordans 1989, and into the elite airborne military service. 1991, by the influence of the Soviet Union, the uggs on sale Russian christian louboutin army general lack of funds, a large number ugg australia of Air Jordan 11 Gamma Blue soldiers seeking veterans, but under extremely difficult conditions still dedicated, praise superiors, and soon was sent to the famous christian louboutin shoes Ryazan Higher ugg Airborne Command School studies. After graduating in 1994, entered the famous Pskov 76th Guards Airborne discount christian louboutin Division, served as discount nike jordans the reconnaissance platoon, reconnaissance ugg soldes deputy company commander, company commander, battalion airborne regiment scouting director and other duties.From 2000 to Cheap Louis Vuitton Handbags 2004, where the forces have repeatedly ordered war with Chechen militants. Because of their opponents in order to form the squad activity and haunted impermanence, the Russians had to ugg boots mobilize elite troops set up large uggs outlet number of small units, "a Discount Louis Vuitton small wholesale jordan shoes play small" Implementation siege. commanding troops in Chechnya, Christian Louboutin Daffodile Ingushetia and other places over the mountains, to track the militants fled. Discount LV Handbags Although the militants were extremely vigilant, but as long as the task has never had outsmarted.August 8, 2008, Georgia suddenly invade South Ossetia (Russian peacekeepers stationed ugg pas cher there), the Russian military to respond quickly, including including the 76th Guards Airborne Division, more than christian louboutin remise 50% 3,000 people were immediately delivered to the pro-Russian Abkhazia, Georgia cheap nike jordan shoes Army contain two infantry brigades, effectively coordinate the cheap christian louboutin direction of the Russian Bags Louis Vuitton troops in South Ossetia.

柯云 said...

2016-07-20keyun
tory burch flats
instyler
kobe 10
christian louboutin shoes
louis vuitton bags
retro 11
michael kors outlet online
louis vuitton outlet
giuseppe zanotti outlet
true religion outlet
supra footwear
ray ban sunglasses
nike blazers shoes
beats by dr dre
adidas yeezy
michael kors handbags
adidas superstar
gucci handbags
michael kors outlet clearance
michael kors handbags
louis vuitton
coach outlet
air max 95
asics shoes for women
tory burch flats
jordan 3 powder blue
cheap toms
kate spade outlet
louboutin femme
nike air max uk
michael kors outlet online
nike sb janoski
kobe shoes 11
fitflop sandals
christian louboutin outlet
fitflop shoes
nike store
true religion jeans
kobe 8

roshini said...


Sage Support Phone Number
Sage 50 Tech Support Phone Number
Sage 50 Support Number
Sage 50 Technical Support Phone Number
Sage 50 Tech Support Number
Sage 50 Technical Support Phone Number
Sage 50 Technical Support Number
Sage 50 Customer Support Phone Number
Sage 50 Customer Service Number

Soni yadav said...

Aol Technical Support Phone Number
Aol Technical Support Number
Aol Tech Support Number
Aol Tech Support phone Number
Aol Support Phone Number
Aol Tech Support Number
Outlook Technical Support Phone Number
Outlook Technical Support Number
Outlook Tech Support Number
Outlook Tech Support Phone Number
Outlook Support Phone Number
Outlook Tech Support Number

Anjilo Jilo said...


Quicken Support Phone Number
Quicken Support Phone Number
Quicken Support Number
Quicken Tech Support Number
Quicken Tech Support Phone Number
Quicken Technical Support Number
Quicken Technical Support Phone Number
Quicken Technical Support Number
Quicken Tech Support Phone Number
Quicken Tech Support Number

mohan kumar said...

Quickbooks Support Phone Number
Quickbooks Payroll Support Phone Number
Quickbooks Payroll Tech Support Number
Quickbooks Payroll Support Number
Quickbooks Payroll Technical Support Number
Quickbooks Payroll Tech Support Phone Number
Quickbooks Payroll Technical Support Phone Number
Quickbooks Payroll Help Desk Phone Number
Quickbooks Payroll Help Desk Number
Quickbooks Payroll Customer Service Number
Quickbooks Payroll Customer Service Phone Number
Quickbooks Payroll Customer Support Number
Quickbooks Payroll Customer Support Phone Number

Hua Cai said...

coach outlet
hollister
cheap oakley sunglasses
rolex watches
nike foamposite
ray ban sunglasses
longchamp handbags
cartier watches for sale
ferragamo shoes
coach outlet
20170114caihuali

raybanoutlet001 said...

michael kors outlet
replica rolex
jimmy choo shoes
patriots jerseys
saints jerseys
cheap ray bans
cheap jordans
dolce and gabbana shoes
ray ban sunglasses
nike blazer low

Mohini Roy said...

Quicken Support Number
Quicken Support Phone Number
Quicken Tech Support Number
Quicken Support Number
Quicken Technical Support Number
Quicken Tech Support Phone Number
Quicken Customer Service Number
Quicken Customer Service Phone Number
Quicken Customer Support Number
Quicken Customer Support Phone Number
Quicken Help Desk Phone Number
Quicken Help Desk Number

Mohini Roy said...

Quicken Tech Support Number
Quicken Support Phone Number
Quicken Tech Support Number
Quicken Support Number
Quicken Technical Support Number
Quicken Tech Support Phone Number
Quicken Customer Service Number
Quicken Customer Service Phone Number
Quicken Customer Support Number
Quicken Customer Support Phone Number
Quicken Help Desk Phone Number
Quicken Help Desk Number