FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18649&edit=1

ID: 18649
Updated by: peacech@gmail.com
Reported By: peacech at gmail dot com
Summary: Allow QuickForm2 to be extensible by the user
Status: Open
Type: Feature/Change Request
Package: HTML_QuickForm2
Package Version: 0.6.0
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

Sorry, typo:

UserApp/HTML/QuickForm2/Element/Button.oho:
->
UserApp/HTML/QuickForm2/Element/Button.php:


Previous Comments:
------------------------------------------------------------------------

[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
}

------------------------------------------------------------------------

Search Discussions

  • Borz_off at Jul 4, 2011 at 8:18 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18649&edit=1

    ID: 18649
    Updated by: borz_off@cs.msu.su
    Reported By: peacech at gmail dot com
    Summary: Allow QuickForm2 to be extensible by the user
    -Status: Open
    +Status: Wont fix
    Type: Feature/Change Request
    Package: HTML_QuickForm2
    Package Version: 0.6.0
    PHP Version: Irrelevant
    Roadmap Versions:
    New Comment:

    -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.


    Previous Comments:
    ------------------------------------------------------------------------

    [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
    }

    ------------------------------------------------------------------------
  • Peacech at Jul 4, 2011 at 8:38 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18649&edit=1

    ID: 18649
    Comment by: peacech@gmail.com
    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:

    How if I want to add a custom method to the Element class, i.e. that
    works on all element types?


    Previous Comments:
    ------------------------------------------------------------------------

    [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
    }

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJul 2, '11 at 2:36a
activeJul 4, '11 at 8:38a
posts3
users3
websitepear.php.net

3 users in discussion

Borz_off: 1 post Peacech: 1 post Peacech: 1 post

People

Translate

site design / logo © 2022 Grokbase