|
QFC - Register Rule: msg#00344php.pear.general
Hi, I'm doing something wrong here, I've just moved a multipage form into the QFC framework. I have a number of genericaly useful function for generating checkbox groups, radio buttons which like a good C programmer I put into a "misc.php" - a number of the checkboxes are for questions such as "choose a,b,c,d,other ) if other then it produces a text box for 'Explanation'. I have a validation function that checks for the "other" option and fails if there is a null value in the text box. // Start of sample code function getCheckBoxExplanationRule($elements,$explFlags) /* -------------------------------------------------------------------- getExplanation Function will test an array of elements to ensure that if an option requies an explanation (from the the Database) it has been entered. The logic for this is simply if an option is followed by a textbox/explanation field and is checked then if that text box is not entered the function returns false. -------------------------------------------------------------------- */ { foreach ($elements as $k=>$v) { $flag = $explFlags[$k]; if ($explFlags[$k] == 'Y') { if (!isset($elements['explFlag']) || ($elements['explFlag'] =="")) { return false; } } } return true; } function getRadioExplanationRule($elements,$explFlags) { foreach ($elements as $k=>$v) { if ($explFlags[$v] == 'Y') { if ((!isset($elements['explFlag'])) || ($elements['explFlag'] == "")) { return false; } } } return true; } // End of code I regisiter the function as follows in the original // more code <code> $this->inputForm->registerRule('checkBoxExpl','function','getCheckBoxExplanationRule','incidentReportForm'); $this->inputForm->registerRule('checkRadioExpl','function','getRadioExplanationRule','incidentReportForm'); $this->inputForm->addRule('incLocation','Please add explanation as required','checkRadioExpl',$this->getExplFlds($this->getReferences($db,'Location'))); // end of code </code> Now I want to call it from a page in qfc, I used the following // <code> require_once "misc.php"; class IncidentPage extends HTML_QuickForm_Page { function buildForm() { // blah - build fields $this->registerRule('checkBoxExpl','function','getCheckBoxExplanationRule'); $this->registerRule('checkRadioExpl','function','getRadioExplanationRule'); } } // </code> This is wrong because it never gets called - should I include all of these functions in a parent form and sub-class that into QFC? Or is it even easier? THanks for the great work on QFC, it is sinpirational. I look forward to working with you as I get this more under control, and hopefully will need services to build things over the next few years. hpfm Barry Steele hpfm solutions pty ltd mob: 0413947980 fax: 0299817727 mailto:: barry@xxxxxxxx -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: dreamweaver templates: 00344, Nick Nettleton |
|---|---|
| Next by Date: | Re: MDB with MS sql server: 00344, Thierry Bothorel |
| Previous by Thread: | QFC - Javascript Button click()i: 00344, Daniel Kopp |
| Next by Thread: | Re: QFC - Register Rule: 00344, Alexey Borzov |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |