Matthew Weier O'Phinney-3 wrote:
>
> -- fab2008 <[EMAIL PROTECTED]> wrote
> (on Wednesday, 12 March 2008, 06:22 PM -0700):
>> Now the problems:
>>
>> 1) Why StringTrim filter is not applied to submitted value? I expect as
>> output the value 'qwerty', but blanks remains in the result...
>
> This is because setElementFilters() applies the filter to all
> *currently* registered elements -- it does not apply to elements
> registered after the fact.
>
> I'd suggest in your original subclass, you do the following:
>
> [...]
>
> Then, in the classes subclassing the above, you would *not* override the
> constructor, but instead implement the init() method for your
> initialization tasks. This would ensure that your StringTrim gets added
> to all elements.
>
>
Ok, understood. Good explanation and good solution.
Matthew Weier O'Phinney-3 wrote:
>
> There was a bug in RC1 with how required elements created the NotEmpty
> validator that is prepended to the validation chain -- the
> 'breakChainOnFailure' flag was getting reset on already instantiated
> validators. I fixed this in svn yesterday, and it's available in both
> the trunk and the 1.5 release branch.
>
Perfect, thank you. It's all the evening that I search for a solution ;-)
Another thing, is there any way to add custom error message to a field or to
the form, without using a validator? I explain better suppose i have a login
form (with username and password fields) and the submitted data is
sintattically valid, but when I use Zend_Auth i have a INVALID_CREDENTIAL
result, i want to insert a "Wrong password" error for the password field,
for the moment i did this adding a custom LoginCheck validator for login
field by using the context parameter for checking password and trigger a
wrong password error, but i'd like to do something like this in my
controllers:
if ($form->isValid($data)) {
// check user and pass with zend auth
$ok = $this->check($form->getValues());
if (!$ok) {
$form->addError('password', 'wrong password for user ' .
$data['login']);
return;
} else {
// forward to account page
$this->_forward('userinfo');
return;
}
}
--
View this message in context:
http://www.nabble.com/Zend_Form-bug-or-am-I-stupid--tp16019346s16154p16019851.html
Sent from the Zend Framework mailing list archive at Nabble.com.