#154 Don't display 'Add page' link for unsaved templates

This commit is contained in:
Mark Nelson 2018-07-12 16:12:24 +08:00
parent 7f592e332f
commit 6070185a61

View file

@ -80,18 +80,20 @@ class edit_form extends \moodleform {
$this->add_customcert_page_elements($page); $this->add_customcert_page_elements($page);
} }
// Link to add another page. // Link to add another page, only display it when the template has been created.
$addpagelink = new \moodle_url('/mod/customcert/edit.php', if (isset($this->_customdata['tid'])) {
array( $addpagelink = new \moodle_url('/mod/customcert/edit.php',
'tid' => $this->tid, array(
'aid' => 1, 'tid' => $this->tid,
'action' => 'addpage', 'aid' => 1,
'sesskey' => sesskey() 'action' => 'addpage',
) 'sesskey' => sesskey()
); )
$icon = $OUTPUT->pix_icon('t/switch_plus', get_string('addcertpage', 'customcert')); );
$addpagehtml = \html_writer::link($addpagelink, $icon . get_string('addcertpage', 'customcert')); $icon = $OUTPUT->pix_icon('t/switch_plus', get_string('addcertpage', 'customcert'));
$mform->addElement('html', \html_writer::tag('div', $addpagehtml, array('class' => 'addpage'))); $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. // Add the submit buttons.
$group = array(); $group = array();