Closed GoogleCodeExporter closed 9 years ago
Hi,
You are totally right.
Thanks for noticing
Update to Revision 621
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 17 Feb 2010 at 1:58
The callback gets called, but the changed field value isn't passed back to the
$post
variable.
// setup
$form->setCallbackBeforeUpdate(array($this,'calbck'));
// function
public function calbck(&$fields) { // or calbck($fields)
$fields['userID'] = 1;
}
Also, is there a way to pass some more params to callback. Like
$form->setCallbackBeforeUpdate(array($this,'calbck'), array('param1', 'param2));
function calbck($fields, $params)
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 10:36
Just found in docs that the function should be called as
call_user_func_array($this->_callbackBeforeUpdate, array(&$post));
This way params are passed by reference.
Or
call_user_func_array(
$this->_callbackBeforeUpdate,
array(
&$post,
array('some param', $this, 'other param')
);
Tried it and it works nice.
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 11:40
Yes.
Again, thanks for reporting.
Check the latest revision
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 17 Feb 2010 at 4:07
Hi,
checked. It works.
However, would it be possible to automatically send the Model as param, if it
is set?
Models often have methods that can be useful. If callback function is not from
the
model, function can not know to which instance of Model the data belong. Or
maybe we
can define custom params?
What do you think?
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 4:41
Hi,
Done.
Check revision 628
Best Regards,
Bento Vilas Boas
Original comment by pao.fre...@gmail.com
on 17 Feb 2010 at 5:08
Hi,
works.
Just for the reference, in callback to change the values we must use reference
if od
array:
public function calbck($params) {
$fields = &$params[0];
$model = &$params[1];
$fields['userID'] = 5;
}
Confirmed and Verified
Original comment by vlatko.b...@gmail.com
on 17 Feb 2010 at 5:18
Original comment by bento.vi...@gmail.com
on 3 Mar 2010 at 4:56
Original issue reported on code.google.com by
vlatko.b...@gmail.com
on 16 Feb 2010 at 6:30