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=””.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s