Monthly Archives: February 2010

How to get InArray working for Zend_Validate with a Zend_Config_Xml object

I ran into a problem today and solved it, so I’m just going to quickly jot it down in the hopes it helps someone out. I’m creating a form out of an xml file and needed an InArray Validator. So here’s how you do it: (The Code and Pre tags aren’t working so I substituted < > with [])

[gender]
	[type]select[/type]
	[options]
		[label]Gender:[/label]
		[required]true[/required]
		[!-- gender is custom defined mootools validation --]
		[class]validate['required','gender'][/class]
		[validators]
			[inarray]
				[validator]InArray[/validator]
				[options]
					[array]male[/array]
					[array]female[/array]
				[/options]
			[/inarray]
		[/validators]
		[multioptions]
			[gender]Choose One[/gender]
			[male]male[/male]
			[female]female[/female]
		[/multioptions]
	[/options]
[/gender]

The only thing that still bugs me is that under multioptions, the Choose One shows up as value=”gender” when I’d like it to have a value=””.

Advertisement