The problem with using array_diff() is that it has to be done before validation, but I would imagine you only want to look for differences after validation.
I think this would be a nice addition to Zend_Form.
-Hector
--
-Hector
On Tue, Oct 14, 2008 at 12:39 PM, Pieter Kokx <pieter@kokx.nl> wrote:
Hi,
PHP's array_diff() function and $form->getValues() should probably do the trick for you ;).
Regards, Pieter Kokx MaakSite.net PHP Developer
Whitcraft, Jon schreef:Hello everyone,
Today while working with Zend Form while using it to edit a form I wanted to have an easy way to check to see if anything changed and then return any fields that have changed. The way I figured this would work is like this in your controller
$defaultValues = array(<some values here>);
$form = new My_Form();
If($form->isValid($_POST)) {
$changedValues = $form->getChangedValues($defaultvalues);
}
That way you could only process any values that changed or skip the processing if nothing changed.
Jon Whitcraft
Indianapolis Motor Speedway
jwhitcraft@brickyard.comP: (317) 492-8623 - F: (317) 492-6419
********************
********************
This E-mail (and attachments) may contain confidential/privileged information intended only for the named addressee(s). If you are not an intended recipient, do not read, copy, disseminate or take any action based on the content of this E-mail. Please notify the sender by reply E-mail and erase this E-mail from your system. Your assistance is appreciated. E-mail transmission may not be secure or error-free. The company is not responsible for any loss/damage arising from any virus transmitted.
********************
********************
--
-Hector
没有评论:
发表评论