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');
                 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!


oakleyses 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

oakleyses 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,

Unknown 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.

Unknown 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

Unknown 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

Unknown said...

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

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

caiyan said...

polo ralph lauren
toms outlet store
air max outlet
beats headphones
fit flops
nike roshe one
michael kors outlet online
coach outlet online
coach outlet store online
levis outlet

Unknown said...

longchamp solde
coach factory outlet
oakley sunglasses
wizards jerseys
trailblazers jerseys
true religion jeans
michael kors outlet
canada goose jackets
true religion jeans
bottega veneta outlet

zzyytt said...

adidas yeezy boost
nike huarache
yeezy 500 blush
yeezy shoes
jordan 11
hermes belts
jordan shoes
jordan shoes
nmd r1

Unknown said...

calvin klein jeans
kate spade outlet
cheap jerseys
pandora charms
oakley sunglasses
fila shoes
christian louboutin outlet
ugg boots
cheap jordans
canada goose outlet