1
trabis
How to use a cancel button?
  • 2007/11/17 0:25

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hello,
I´m creating a form and I added a button to cancel the operation. The problem is that I have required fileds in the form and when I click the 'cancel' button XOOPS asks me to write in the required fields.

This is the code:
$button_tray = new XoopsFormElementTray('' ,'');

$submit_btn = new XoopsFormButton('''post'_MD_XTL_POST'submit');
$submit_btn->setExtra('accesskey="s"');
$button_tray->addElement($submit_btn);

$cancel_btn = new XoopsFormButton('''cancel'_MD_XTL_CANCEL'submit');
$cancel_btn->setExtra('accesskey="c"');
$button_tray->addElement($cancel_btn);

$sform->addElement($button_tray);


What can I do here?

2
suico
Re: How to use a cancel button?
  • 2007/11/17 2:56

  • suico

  • Friend of XOOPS

  • Posts: 374

  • Since: 2003/7/24


The code is wrong try like this:

$button_tray = new XoopsFormElementTray('' ,'');

$submit_btn = new XoopsFormButton('''post'_MD_XTL_POST'submit');
$submit_btn->setExtra('accesskey="s"');
$button_tray->addElement($submit_btn);

$cancel_btn = new XoopsFormButton('''cancel'_MD_XTL_CANCEL'reset');
$cancel_btn->setExtra('accesskey="c"');
$button_tray->addElement($cancel_btn);

$sform->addElement($button_tray);
Yogurt Social Network Service
Visit:http://www.marcellobrandao.eti.br/

3
trabis
Re: How to use a cancel button?
  • 2007/11/17 17:17

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Thanks Suico!
So simpleeeeeeeeeee, eheh.

[portuguese]
Excelente o seu trabalho com o yogurt network, parabéns!
[/potuguese]

4
trabis
Re: How to use a cancel button?
  • 2007/11/17 18:11

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Actually it did not work, oops.

I did not want a reset button to clear the fields but a cancel button to take me back where I were before.

I looked in this forum submit form (that has a cancel post button) and into the formbutton.php and I got my answer:


$button_tray = new XoopsFormElementTray('' ,'');

$submit_btn = new XoopsFormButton('''post'_MD_XTL_POST'submit');
$submit_btn->setExtra('accesskey="s"');
$button_tray->addElement($submit_btn);

$cancel_btn = new XoopsFormButton('''cancel'_MD_XTL_CANCEL'button');
$cancel_btn->setExtra('accesskey="c"');
$cancel_btn->setExtra('onclick='location="mymodules.php"'');
$button_tray->addElement($cancel_btn);

$sform->addElement($button_tray);


Anyway thanks a lot for your time suico!

Login

Who's Online

155 user(s) are online (98 user(s) are browsing Support Forums)


Members: 0


Guests: 155


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits