FORMfields, the premiere web framework
Login
Support Home | Knowledge Base | Documentation | Forums | Contact Us
Info
FORMfields & FORMgen :: Generated Forms

Defining a Clear Button Listener - Clearing Some Fields

(1983 views. Last Updated: 2007-08-08 6:39 PM)

Here is an example of how to define your own custom ClearButtonListener so that only some of your fields are cleared when "Clear" is clicked. This example assumes that you want to clear all the fields except for "name", which is defaulted to "Jon Doe". Edit your form and replace:
    if ($ffForm->fieldExists("ff_clear")) {
        $ffForm->formFields["ff_clear"]->addButtonListener(new FfClearButtonListener());
    }
with:
    class ClearButtonListener extends FfButtonListener
    {
        function onClick(&$ffForm)
        {
            $ffForm->clearAllData();
            $ffForm->setValue("name", "Jon Doe");
        }
    }
    if ($ffForm->fieldExists("ff_clear")) {
        $ffForm->formFields["ff_clear"]->addButtonListener(new ClearButtonListener());
    }
Info
Support | Earn Money
Copyright © 2005-2019 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.