diff --git a/classes/edit_form.php b/classes/edit_form.php index 9c1d0345..a5640f8d 100644 --- a/classes/edit_form.php +++ b/classes/edit_form.php @@ -55,7 +55,7 @@ class edit_form extends \moodleform { * Form definition. */ public function definition() { - global $DB; + global $DB, $OUTPUT; $mform =& $this->_form; @@ -80,11 +80,11 @@ public function definition() { $this->add_customcert_page_elements($page); } - $mform->closeHeaderBefore('addcertpage'); - - $mform->addElement('submit', 'addcertpage', get_string('addcertpage', 'customcert')); - - $mform->closeHeaderBefore('submitbtn'); + // Link to add another page. + $addpagelink = new \moodle_url('/mod/customcert/edit.php', array('tid' => $this->tid, 'aid' => 1, 'action' => 'addpage')); + $icon = $OUTPUT->pix_icon('t/switch_plus', get_string('addcertpage', 'customcert')); + $addpagehtml = \html_writer::link($addpagelink, $icon . get_string('addcertpage', 'customcert')); + $mform->addElement('html', \html_writer::tag('div', $addpagehtml, array('class' => 'addpage'))); // Add the submit buttons. $group = array(); diff --git a/edit.php b/edit.php index 9061157d..292ca41e 100644 --- a/edit.php +++ b/edit.php @@ -66,7 +66,6 @@ $PAGE->navbar->add(get_string('editcustomcert', 'customcert')); } - // Flag to determine if we are deleting anything. $deleting = false; @@ -84,6 +83,11 @@ case 'emovedown' : $template->move_item('element', $actionid, 'down'); break; + case 'addpage' : + $template->add_page(); + $url = new \moodle_url('/mod/customcert/edit.php', array('tid' => $tid)); + redirect($url); + break; case 'deletepage' : if (!empty($confirm)) { // Check they have confirmed the deletion. $template->delete_page($actionid); @@ -182,11 +186,6 @@ // Save any page data. $template->save_page($data); - // Check if we are adding a page. - if (!empty($data->addcertpage)) { - $template->add_page(); - } - // Loop through the data. foreach ($data as $key => $value) { // Check if they chose to add an element to a page. diff --git a/lang/en/customcert.php b/lang/en/customcert.php index b4f084ef..1d9d7e1c 100644 --- a/lang/en/customcert.php +++ b/lang/en/customcert.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['addcertpage'] = 'Add another certificate page'; +$string['addcertpage'] = 'Add page'; $string['addelement'] = 'Add element'; $string['awardedto'] = 'Awarded to'; $string['certificate'] = 'Certificate'; diff --git a/styles.css b/styles.css index 04a6aa06..9fbe30bf 100644 --- a/styles.css +++ b/styles.css @@ -2,6 +2,11 @@ text-align: right; } +#page-mod-customcert-edit .addpage { + border-top: 1px solid #f4f4f4; + text-align: right; +} + #page-mod-customcert-edit #id_replace { margin-left: 10px; }