[nycphp-talk] mystery parameter for process method in PEAR HTML_QuickForm
Jayesh Sheth
jayeshsh at ceruleansky.com
Tue Jun 15 23:42:16 EDT 2004
Hello all,
I have reading up on the PEAR HTML_QuickForm library, and trying to use
it in a new (prototype of an) application.
I have been reading David Sklar's book, and reading through his online
presentation, but still some questions remain unanswered.
Perhaps some of you on this will have answer to this question:
In the slide at this address -
http://www.sklar.com/talks/show.php/nyphp-quickform/5 - there is this
snippet of code:
$form->process('say_hello');
/* ... */
function say_hello($data) {
print 'Hello, ' . $data['my_name'];
}
So, my question is this: when the callback function say_hello() was
specified in the statement "$form->process('say_hello');" no parameter
seems to have been passed to it (explicitly, that is).
But, in this example, the something like the following output is
expected to be printed:
Hello, Jay
where "Jay" is the value of the name entered into the name input box
(the code for which is not shown above).
So, where does the $data information come from? Is it somehow implicitly
passed through to the say_hello() callback function when the
"$form->process('say_hello');" statement is made?
The code for the process method from the HTML/QuickForm.php file is as
follows:
// *****************************************************
/**
* Performs the form data processing
*
* @param mixed $callback Callback, either function
name or array(&$object, 'method')
* @param bool $mergeFiles Whether uploaded files
should be processed too
* @since 1.0
* @access public
* @throws HTML_QuickForm_Error
*/
function process($callback, $mergeFiles = true)
{
if (!is_callable($callback)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_PROCESS,
null, E_USER_WARNING, "Callback function does not exist in
QuickForm::process()", 'HTML_QuickForm_Error', true);
}
$values = ($mergeFiles === true) ?
HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) :
$this->_submitValues;
return call_user_func($callback, $values);
} // end func process
// *******************************************************
I hope my question makes sense. If not, I will try to reword it.
Best Regards,
- Jay
More information about the talk
mailing list