Hi there!

I'm looking for a hint on the following problem using the components, 
any help appreciated.
One of my templates provides a form with an input field called "password":

<form action="/authenticate" method="post">
        <fieldset>
                <input name="password" id="password" class="textinput" 
type="password" />
                <button type="submit">Login</button>
        </fieldset>
</form>

Any submit will call the action slot "authenticate" that will validate 
the form data according to my form definition:

private static function getFormDefinition() {

        $definition = array(
                'password' => new ezcInputFormDefinitionElement(
                        ezcInputFormDefinitionElement::REQUIRED,
                        'callback',
                        array('appFormTools', 'checkEmpty')
                )
        );
        return $definition;

}

Here's the callback function for the password:

class appFormTools {

        public static function checkEmpty($string) {
        
                $string = filter_var($string, FILTER_SANITIZE_STRING);
                if (strlen($string) !== 0) {
                        return $string;
                } else {
                        return false;
                }
        
        }

}

I decided to use a custom callback method to produce an invalid result 
in case of an empty string for the password.
I understand that the filter "string" will validate in case of an empty 
string as the POST-parameter "password" is still available.

Action "authenticate" now tries to validate the form using my form 
definition:

$definition = self::getFormDefinition();
$form = new ezcInputForm(INPUT_POST, $definition);

Assuming that I have submitted the form containing an empty string for 
the password, $form->hasValidData('password') still validates. Why? The 
callback function returns boolean false, it should be rendered invalid...

Any ideas?

Thanks a lot,
Simon
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to