Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not really a complete answer to your question, but since comments don't have syntax formatting; here's a filter you can use to make your field values null if empty.</p> <pre><code>class My_Filter_NullIfEmpty implements Zend_Filter_Interface { public function filter( $value ) { // maybe you need to expand the conditions here if( 0 == strlen( $value ) ) { return null; } return $value; } } </code></pre> <p>About the required part: I'm not sure really. You could try to search the ZF mailinglists on Nabble:</p> <p><a href="http://www.nabble.com/Zend-Framework-Community-f16154.html" rel="nofollow noreferrer">http://www.nabble.com/Zend-Framework-Community-f16154.html</a></p> <p>Or subscribe to their mailinglist, and ask them the question. Either through Nabble, or directly via the addresses on framework.zend.com: <a href="http://tinyurl.com/y4f9lz" rel="nofollow noreferrer">http://tinyurl.com/y4f9lz</a></p> <p>Edit: Ok, so now I've done some tests myself, cause what you said all sounded counter intuitive to me. Your example works fine with me. This is what I've used:</p> <pre><code>&lt;?php class Form extends Zend_Form { public function init() { $title = new Zend_Form_Element_Text('title', array( 'label' =&gt; 'Title', 'required' =&gt; false, 'filters' =&gt; array( 'StringTrim', 'HtmlEntities', 'NullIfEmpty' // be sure this one is available ), 'validators' =&gt; array( array('StringLength', false, array(3, 100)) ), )); $this-&gt;addElement( $title ); } } $form = new Form(); $postValues = array( 'title' =&gt; '' ); // or $postValues = array( 'title' =&gt; ' ' ); // or $postValues = array( 'title' =&gt; 'ab' ); // or $postValues = array( 'title' =&gt; ' ab ' ); // or $postValues = array( 'title' =&gt; '&lt;abc&gt;' ); // all work perfectly fine with me // validate the form (which automatically sets the values in the form object) if( $form-&gt;isValid( $postValues ) ) { // retrieve the relevant value var_dump( $form-&gt;getValue( 'title' ) ); } else { echo 'form invalid'; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload