Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.6

Request #6036 interface to add further Quickform-Elements
Submitted: 2005-11-22 13:23 UTC Modified: 2006-12-16 05:42 UTC
From: arne dot bippes at brandao dot de Assigned: wiesemann
Status: Closed Package: DB_Table
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-11-22 13:23 UTC] arne dot bippes at brandao dot de
Description: ------------ Currently QuickForm::getElement() creates unknown Elements with a standard parameter set. There is no possibilty to add custom QuickForm-Elements which needs further parameters. Therefore an interface to add custom HTML_QuickForm::createElement()-calls is needed. A solution might be to just define a qf_type (e.g. function) which instances a class and calls a defined function which is returning an $element. The following easy code does everything i need and is working for me (see test-script) Test script: --------------- #### in the case-statement of QuickForm::getElement() ### case 'static': .... break; /** START NEW CODE */ case 'function': if ( class_exists($col['qf_class']) && is_callable(array($col['qf_class'],'getElement') )) { $qf_class =& new $col['qf_class']; $element =& $qf_class->getElement($col,$elemname,$setval); break; } /** END NEW CODE */ default: .... #### the column definition #### $col ...: 'email_an' => array( 'type' => 'varchar', 'qf_type' => 'function', 'qf_class' => 'Bdo_advinput', 'qf_advlabel' => '(z.B. empfaenger@t-systems.com)', 'qf_label' => _('E-Mail Adresse des Empfaengers'), ), ### the class where the getElement()-Method is called ### class Bdo_advinput { function getElement(&$col, &$elemname, &$setval) { $element =& HTML_QuickForm::createElement( 'advinput', $elemname, $col['qf_label'], $col['qf_advlabel'], (isset($setval) ? $setval : '') ); return $element; } }

Comments

 [2005-11-22 16:20 UTC] wiesemann
Hi Arne, I understand your request and I'm willing to implement such a thing. But: - I'm not happy with qf_type = 'function', we should try to find a more suitable name for it (maybe 'custom'?) - Without having tested your code or trying modifications of it: A static way like it is done for the "normal" elements seems to be impossible here, right? Beside that, why not call getElement() createElement()? (=> consistent naming) It would be very helpful for my tests, if you could provide me your advinput element via email (in German, if you want *g*). (No problem, if you don't want to do that, independent whatever the reason might be.) (just had a look into the manual: call_user_func() might be a option to do it statically, I'll try that)
 [2005-11-23 11:14 UTC] wiesemann
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. --------------- Hi Arne, thanks for your code and the idea. You are right, 'callback' is an even better name. I made some modifications to your last code suggestion because the "method only" variant (without an object) wouldn't have been called otherwise. Please try QuickForm.php from CVS and reopen this if it doesn't work for you as expected.
 [2005-11-23 12:23 UTC] arne dot bippes at brandao dot de
Works perfectly. Thanks!