How to add "Reset Form" button

I would like to add a "Reset Form" button to allow the user to clear the input fields.

I've read the document "Using Formulize and Pageworks to Create Custom Applications" and I've search these forums but I can't find anything that explains how to do this.

Has anyone figured out how to do this? Thanks.

Comments

Re: How to add "Reset Form" button

OK. I figured out to do this.

I've added these lines of code to the include file formdisplay.php in the formulize module.


$butt_cancel = new XoopsFormButton('', '', _CANCEL, 'button');
$butt_cancel->setExtra('onclick="history.go(-1)"');
$buttontray->addElement($butt_cancel);

$reset_btn = new XoopsFormButton('', 'reset', _FORM_RESET, 'reset');
$buttontray->addElement($reset_btn);

I've added these starting at line 860. This causes 2 buttons to be added to the button tray before the "Save" or "All Done" button is added: a Cancel button and a Reset button.

I have defined _FORM_RESET in the xoops global.php with a value of "Clear Input".

Re: How to add "Reset Form" button

That's terrific Tom, that's exactly where and how you would need to do this. Nice job. :-)

I think we need some stronger controls for which buttons appear when at the bottom of the form and what they're called, and if we had that, then including a reset button as an option would be a piece of cake.

In the meantime, I'm not sure how to handle this change, since I think for most applications, the reset button would be distracting...a lot of users just want a save button and nothing else, it cuts down on confusion. So I don't want to add a reset button automatically to the bottom of every form. Hence the need for more controls (either at the form level, or a new screen type for "regular version of the form").

I will keep this on file and think about how to accommodate this so you don't have to keep patching your copy of Formulize to keep this change working, every time there's a new release.

Take it easy,

--Julian

Re: How to add "Reset Form" button

Julian,

I agree with your comments. In my case I am trying to make sure I provide consistency across all the different xoops modules I am using. Some modules have Cancel and/or Reset, others just have Submit (or similar). I am also aiming to make sure that the order in which the buttons appears is consistent so that the users know to look for Cancel, then Reset on the left, Submit on the right and any others in between.