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

Clear Button Doesn't Clear Default Values

(2028 views. Last Updated: 2007-08-10 3:47 PM)

To enable the clear button to clear your default values (as it should), edit FORMfields/src/FfForm.php and replace:
        function performActions()
        {
            foreach ($this->formFields as $i=>$field) {
                if (is_a($field, "SubmitField") && !$field->isEmpty() && sizeof($field->buttonListeners) > 0) {
                    foreach ($field->buttonListeners as $j=>$listener) {
                        $this->formFields[$i]->buttonListeners[$j]->onClick($this);
                    }
                }
            }
            
            if (!$this->getButtonClicked() && sizeof($this->formListeners) > 0) {
                foreach ($this->formListeners as $i=>$listener) {
                    $this->formListeners[$i]->onNoClicks($this);
                }
            }
        }
with:
        function performActions()
        {
            $clicked = false; // If the SubmitField calls clearAllData then even the clear click itself is cleared. We should not ignore this click.
            foreach ($this->formFields as $i=>$field) {
                if (is_a($field, "SubmitField") && !$field->isEmpty() && sizeof($field->buttonListeners) > 0) {
                    foreach ($field->buttonListeners as $j=>$listener) {
                        $this->formFields[$i]->buttonListeners[$j]->onClick($this);
                        $clicked = true;
                    }
                }
            }
            
            if (!$clicked && !$this->getButtonClicked() && sizeof($this->formListeners) > 0) {
                foreach ($this->formListeners as $i=>$listener) {
                    $this->formListeners[$i]->onNoClicks($this);
                }
            }
        }
Info
Support | Earn Money
Copyright © 2005-2019 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.