Fixed issue where page with id 1 exists
This commit is contained in:
parent
b3676b3f63
commit
362cc5f092
2 changed files with 11 additions and 11 deletions
|
@ -67,7 +67,7 @@ class edit_form extends \moodleform {
|
||||||
} else { // Add a new template.
|
} else { // Add a new template.
|
||||||
// Create a 'fake' page to display the elements on - not yet saved in the DB.
|
// Create a 'fake' page to display the elements on - not yet saved in the DB.
|
||||||
$page = new \stdClass();
|
$page = new \stdClass();
|
||||||
$page->id = 1;
|
$page->id = 0;
|
||||||
$page->sequence = 1;
|
$page->sequence = 1;
|
||||||
$this->add_customcert_page_elements($page);
|
$this->add_customcert_page_elements($page);
|
||||||
}
|
}
|
||||||
|
|
20
edit.php
20
edit.php
|
@ -162,23 +162,23 @@ if ($data = $mform->get_data()) {
|
||||||
$rightmargin = 'pagerightmargin_' . $pageid;
|
$rightmargin = 'pagerightmargin_' . $pageid;
|
||||||
$rightmargin = 'pagerightmargin_' . $pageid;
|
$rightmargin = 'pagerightmargin_' . $pageid;
|
||||||
|
|
||||||
|
$data->$width = $data->pagewidth_0;
|
||||||
|
$data->$height = $data->pageheight_0;
|
||||||
|
$data->$leftmargin = $data->pageleftmargin_0;
|
||||||
|
$data->$rightmargin = $data->pagerightmargin_0;
|
||||||
|
|
||||||
// We may also have clicked to add an element, so these need changing as well.
|
// We may also have clicked to add an element, so these need changing as well.
|
||||||
if (isset($data->element_1) && isset($data->addelement_1)) {
|
if (isset($data->element_0) && isset($data->addelement_0)) {
|
||||||
$element = 'element_' . $pageid;
|
$element = 'element_' . $pageid;
|
||||||
$addelement = 'addelement_' . $pageid;
|
$addelement = 'addelement_' . $pageid;
|
||||||
$data->$element = $data->element_1;
|
$data->$element = $data->element_0;
|
||||||
$data->$addelement = $data->addelement_1;
|
$data->$addelement = $data->addelement_0;
|
||||||
|
|
||||||
// Need to remove the temporary element and add element placeholders so we
|
// Need to remove the temporary element and add element placeholders so we
|
||||||
// don't try add an element to the wrong page.
|
// don't try add an element to the wrong page.
|
||||||
unset($data->element_1);
|
unset($data->element_0);
|
||||||
unset($data->addelement_1);
|
unset($data->addelement_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data->$width = $data->pagewidth_1;
|
|
||||||
$data->$height = $data->pageheight_1;
|
|
||||||
$data->$leftmargin = $data->pageleftmargin_1;
|
|
||||||
$data->$rightmargin = $data->pagerightmargin_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save any data for the template.
|
// Save any data for the template.
|
||||||
|
|
Loading…
Reference in a new issue