From db77666426e101c2bb374947af6193570b564e10 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 20 Nov 2012 20:27:07 +0100 Subject: sqlbox: Add a simple form using formslib --- sqlbox/sqlbox_form.php | 18 ++++++++++++++++++ sqlbox/view.php | 9 +++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 sqlbox/sqlbox_form.php (limited to 'sqlbox') diff --git a/sqlbox/sqlbox_form.php b/sqlbox/sqlbox_form.php new file mode 100644 index 0000000..6569595 --- /dev/null +++ b/sqlbox/sqlbox_form.php @@ -0,0 +1,18 @@ +libdir.'/formslib.php'); + +class mod_sqlbox_form extends moodleform { + + public function definition() { + $mform = $this->_form; + $mform->addElement('header', 'general', 'SQLBox'); + $mform->addElement('text', 'query', 'Query', 'size="50"'); + $mform->addElement('editor', 'query2', 'Query2'); + $mform->addElement('submit', 'button', 'Submit'); + } +} + +?> diff --git a/sqlbox/view.php b/sqlbox/view.php index e2330e1..96c3e36 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -31,6 +31,7 @@ require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once(dirname(__FILE__).'/lib.php'); +require_once(dirname(__FILE__).'/sqlbox_form.php'); $id = optional_param('id', 0, PARAM_INT); // course_module ID, or $n = optional_param('n', 0, PARAM_INT); // sqlbox instance ID - it should be named as the first character of the module @@ -74,12 +75,8 @@ if ($sqlbox->intro) { // Conditions to show the intro can change to look for own // Replace the following lines with you own code echo $OUTPUT->heading('Yay! It works!'); -$form = << - -EOF; - -echo $OUTPUT->heading($form); +$form = new mod_sqlbox_form(NULL, array()); +$form->display(); // Finish the page echo $OUTPUT->footer(); -- cgit