Ah thx, that is better.
I have another strange behavior:
In my parent I set Inputfilter I set
$inputfilter->add(array(
'name' => 'parentUserId',
'allow_empty' => true
));
on an optional select and in the child class I extend that with a custom
validator:
$this->get('main')->add(array(
'name' => 'parentUserId',
'validators' => array(
$this->validParentUserIdAssignmentRoleValidator
)
));
The Problem now is that the new add() seems to reset the allow_empty.
Before the second add():
["notEmptyValidator":protected] => bool(false)
["required":protected] => bool(false)
After the second add():
["notEmptyValidator":protected] => bool(false)
["required":protected] => bool(true)
Is that intended?
> -----Ursprüngliche Nachricht-----
> Von: Matthew Weier O'Phinney [mailto:[email protected]]
> Gesendet: Dienstag, 3. September 2013 17:45
> An: lists lists
> Betreff: Re: [fw-general] Changing Validator in a extending class
>
> On Thu, Aug 29, 2013 at 9:00 AM, Marc Tempelmeier <m.tempelmeier@bqs-
> institut.de> wrote:
> > i want to change a validator I set in a inputfilter parent class.
> >
> > I´ll do that with:
> >
> > $validators =
> > $this->get('main')->get('username')->getValidatorChain()->getValidator
> > s();
> >
> > $validators[2]['instance']->setOptions(
> > array(
> > 'pattern' => '/^[@a-zA-Z0-9_-]+$/',
> > )
> > );
> >
> > I know there is a plugin-Method on the validator chain, but that returns a
> new instance. Is there a better way to do that?
>
> That's the only way currently to do it, though I'd do it slightly
> differently: loop through the validators and compare them via "instanceof"
> to ensure you operate only on the correct type of validator.
>
> --
> Matthew Weier O'Phinney
> Project Lead | [email protected]
> Zend Framework | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
>