On Wed, Dec 9, 2009 at 6:19 AM, Andrei Iarus <poni1...@yahoo.com> wrote:
>
> Hello,
>
> Is there any integrated solution (in ZF) to throw Exceptions (or simple 
> check), when some extra parameters have been passed to $form->validate( 
> $postParams ) ??
>
> Should we rely on Zend Form that no extra parameters get to our models?
>
> Thanks.

If you pass $form->getValues() to your models instead of $postParams,
extra post parameters shouldn't matter, should they? The array
returned by the getValues() method of Zend_Form will only contain keys
for actual form fields, and the values of all of those keys will have
been processed by the filters and validators bound to those elements.

I suppose if you need to be absolutely sure that nothing else was
passed, you could do something like this:

<?php

if (count(array_diff_key($form->getValues(), $postParams)) {
    throw new Exception('Extra data passed to Zend_Form');
}

?>



Andrew

Reply via email to