Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37687

Re: forms fun

$
0
0
by Davo Smith.  

If you want two forms on one page, just create two Moodle form objects, do all the usual cancel / get_data checks on them (one after the other), then output them both. e.g.:

if ($form1->is_cancelled()) { ... }
if ($data = $form1->get_data()) { ... }
if ($form2->is_cancelled()) { ... }
if ($data = $form2->get_data()) { ... }
$form1->display();
$form2->display();

As for clearing forms when they are submitted, the easiest way is to finish the data processing section of the form with:

redirect($PAGE->url); // Or manually generate a suitable moodle_url

This will wipe out all the POST vars from the page and leave users with a nice clean form to work with.

Davo


Viewing all articles
Browse latest Browse all 37687

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>