[suspicious - maybe spam] Patch for HTML_QuickForm_Controller to associate events with QuickForm's elements that are not buttons.

From: Date: Mon, 24 Jan 2005 18:59:23 +0000
Subject: [suspicious - maybe spam] Patch for HTML_QuickForm_Controller to associate events with QuickForm's elements that are not buttons.
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35706@lists.php.net to get a copy of this message
The attached patch, allows to associate an event to an element that is not a button. For example an event associated with a select box that is changed. Requeriments: - JavaScript supported in browser - The form must have a hidden input with name _qf__submit initally empty. - The page must have a JavaScript function that submits the form and sets _qf__submit, for example: <head> <script> <!-- /* Submits form with JavaScript @param que string that specifies event of the form page_id:event_id */ function envia(que){ document.forms[0]._qf__submit.value=que; document.forms[0].submit(); } // --> </script> </head> - Each QuickForm element (let's say $dep) that can generate an event when is updated must have the attribute onchange whose value must be a string pag_id:event_id $dep->updateAttributes(array('onchange' => 'envia(\'consultaWeb:id_departamento\')')); - The buttons of the form must have a new attribute onClick='document.forms[0]._qf__submit.value=\'\'' for example: $sel->updateAttributes(array('onClick' => 'document.forms[0]._qf__submit.value=\'\'')); - There must be a class to handle the event, and it must be registered: $this->addAction('id_departamento', new CamDepartamento()); The pieces of code shown are part of an example (dependet select boxes that update information from a database) available at: https://bancodat.dhcolombia.info/divipol/consulta_web.php The sources are available at: http://sivel.sf.net/divipol.tar.gz these sources requires Pear::DB, Pear::HTML_QuickForm_Controller God illumiante us. -- Dios, por favor, ayudanos a hacer Tu voluntad que es felicidad desbordante. http://www.primarilypublicdomain.org/letter/ -- Vladimir Támara Patiño. http://www.geocities.com/v-tamara

Index: Controller.php =================================================================== RCS file: /repository/pear/HTML_QuickForm_Controller/Controller.php,v retrieving revision 1.10 diff -u -r1.10 Controller.php --- Controller.php 1 Oct 2004 09:48:35 -0000 1.10 +++ Controller.php 25 Jan 2005 23:02:44 -0000 @@ -325,6 +325,13 @@ if (is_array($this->_actionName)) { return $this->_actionName; } + if (isset($_REQUEST['_qf__submit'])) { + $matches = explode(':', $_REQUEST['_qf__submit'], 2); + if (isset($this->_pages[$matches[0]])) { + return $matches; + } + } + $names = array_map('preg_quote', array_keys($this->_pages)); $regex = '/^_qf_(' . implode('|', $names) . ')_(.+?)(_x)?$/'; foreach (array_keys($_REQUEST) as $key) {
« previous php.pear.dev (#35706) next »