Edit report at http://pear.php.net/bugs/bug.php?id=18649&edit=1
ID: 18649
Updated by: [email protected]
Reported By: peacech at gmail dot com
Summary: Allow QuickForm2 to be extensible by the user
Status: Wont fix
Type: Feature/Change Request
Package: HTML_QuickForm2
Package Version: 0.6.0
PHP Version: Irrelevant
Roadmap Versions:
New Comment:
http://en.wikipedia.org/wiki/Decorator_pattern
Previous Comments:
------------------------------------------------------------------------
[2011-07-04 10:37:48] char101
How if I want to add a custom method to the Element class, i.e. that
works on all element types?
------------------------------------------------------------------------
[2011-07-04 10:17:39] avb
-Status: Open
+Status: Wont fix
I fail to see why you want custom classes to have the same names as
those in the package, this can only lead to confusion and debug
problems. You can register any class you like with
HTML_QuickForm2_Factory::registerElement('button',
'YourCustomClassName');
and then $form->addButton() will add an instance of your custom class to
the form.
------------------------------------------------------------------------
[2011-07-02 04:36:00] char101
Sorry, typo:
UserApp/HTML/QuickForm2/Element/Button.oho:
->
UserApp/HTML/QuickForm2/Element/Button.php:
------------------------------------------------------------------------
[2011-07-02 04:34:14] char101
Description:
------------
Hi,
With the chained method style of QuickForm2,
it'd be great if we can add our own method to the chain
$form->addButton(...)->myMethod(...);
Currently I have to do this
function myMethod(Button $btn, ...) { ... }
myMethod($form->addButton(...), ...);
which works but not so elegant.
Therefore I propose that QuickForm2 use a cascading filesystem (inspired
by
Kohana Framework): Put all current implementation in it's own private
namespace
e.g. HTML_QuickForm2_Impl . Make an empty classes in HTML_QuickForm2
that extends
the respective class in HTML_QuickForm2_Impl . The user can then make
his own classes
in HTML_QuickForm2 that extends the class in HTML_QuickForm2_Impl and
contain his
custom methods.
PEAR/HTML/QuickForm2/Impl/Element/Button.php:
class HTML_QuickForm2_Impl_Element_Button extends
HTML_QuickForm2_Element
{
// implementation methods
}
PEAR/HTML/QuickForm2/Element/Button.php:
class HTML_QuickForm2_Element_Button extends
HTML_QuickForm2_Impl_Element_Button
{
// Empty class
}
UserApp/HTML/QuickForm2/Element/Button.oho:
class HTML_QuickForm2_Element_Button extends
HTML_QuickForm2_Impl_Element_Button
{
function myMethod() { ... }
}
function my_autoload($class)
{
// search in UserApp first
// if not found search in PEAR
}
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18649&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.