Zend Framework notEmpty validator setRequired
===

I have looked at other [questions][1]/Googled this. My problem is that when I submit my form with empty textboxes that have a `notEmpty` validator, it triggers no error.

First, I would like to see if I understand the difference between `notEmpty` and `setRequired`. As I understand, the `notEmpty` validator gives an error if an element is submitted and the value is empty. That is, if an entry does not exist in the POST data (for forms), then it does not generate an error if the element is not *required*. Like it only runs if the element is *set*. The `setRequired` method will automatically add a `notEmpty` validator behind the scenes unless told otherwise. This ensures that an entry for an element must exist and it must not be empty. Correct?

Now, I tried to use this logic in my form where I added `notEmpty` validators, like so:

    $username = new Zend_Form_Element_Text('txtUsername');
    $username->addValidator(new Zend_Validate_NotEmpty(), true);

And the same for other text fields. If I submit my form without entering a value, my POST data looks like this:

    (
        [txtUsername] => 
        [txtPassword] => 
        [txtRepeatPassword] => 
    )

However, `isValid` still evaluates to `true` and no error messages are generated. Why? Shouldn't the `notEmpty` validator determine that the values are empty since the element has an entry in the POST data? If I use `setRequired(true)`, it works how I want. It just messes with my mind that it determines that the username is not empty when the value is an empty string. :-)

Thanks in advance.

  [1]: http://stackoverflow.com/questions/3871460/zend-form-setrequiredtrue-or-addvalidatornotempty