<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stormwild Interactive &#187; Zend</title>
	<atom:link href="http://blog.stormwild.net/tag/zend/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stormwild.net</link>
	<description>Web Development</description>
	<lastBuildDate>Wed, 07 Jul 2010 14:59:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Zend_Form: How to set message for NotEmpty when setRequired(true)</title>
		<link>http://blog.stormwild.net/programming/zend_form-how-to-set-message-for-notempty-when-setrequiredtrue/</link>
		<comments>http://blog.stormwild.net/programming/zend_form-how-to-set-message-for-notempty-when-setrequiredtrue/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:11:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://stormwild.net/blog/?p=26</guid>
		<description><![CDATA[When, in a subclass of Zend_Form, a Zend_Form_Element is setRequired(true) it automatically adds a NotEmpty validator using the default message. To override the default message add a NotEmpty validator at the top of the list of validators and set breakChainOnFailure &#8230; <a href="http://blog.stormwild.net/programming/zend_form-how-to-set-message-for-notempty-when-setrequiredtrue/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When, in a subclass of Zend_Form, a Zend_Form_Element is setRequired(true) it automatically adds a NotEmpty validator using the default message. To override the default message add a NotEmpty validator at the top of the list of validators and set <span>breakChainOnFailure</span> to true.</p>
<pre>$username = new Zend_Form_Element_Text('username');
$username-&gt;setLabel('Username')
-&gt;setRequired(true)
-&gt;addFilter('StripTags')
-&gt;addFilter('StringTrim')
-&gt;addValidator('NotEmpty', true, array(
     'messages' =&gt; array(
          'isEmpty' =&gt; 'Username is required'
     )
  ))
-&gt;addValidator('Alnum', false, array(
     'messages' =&gt; array(
          'notAlnum' =&gt; 'Use only letters and numbers'
     )
  ));</pre>
<p>
The solution, given by <a href="http://weierophinney.net/" target="_blank">Matthew Weier O&#8217;Phinney</a>,  was found in the following thread:</p>
<p><a href="http://www.nabble.com/Form-Validation-Messages-td15351486.html" target="_blank">Form Validation Messages</a></p>
<p>Related threads:</p>
<p><a href="http://www.nabble.com/how-to-set-error-message-for-Required-form-validator--td18427046.html" target="_blank">how to set error message for Required form validator?</a></p>
<p><a href="http://stackoverflow.com/questions/34848/using-zend-framework-and-setting-a-zendformelement-form-field-to-be-required-h" target="_blank">Using Zend Framework and setting a Zend_Form_Element form field to be required, how do I change the validator used to ensure that the element is not blank</a></p>
<p><a href="http://framework.zend.com/issues/browse/ZF-2806" target="_blank">Zend_Form_Element NotEmpy validation when required is set to true</a></p>
<p>The validation failure message keys, i.e. isEmpty, notAlnum, can be found in the <a href="http://framework.zend.com/apidoc/core/" target="_blank">API Docs</a> or by directly reading the validation class file in the library/Zend/Validate folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stormwild.net/programming/zend_form-how-to-set-message-for-notempty-when-setrequiredtrue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
