mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUGFIX Don't require ParentModeField in CMSpageAddController submissions, to allow for easier programmatical submission of "add page" form (via CMS tree). Reset any selected parent nodes in the interface instead
This commit is contained in:
parent
1fa54abf6c
commit
6ec6b107ca
@ -97,11 +97,8 @@ class CMSPageAddController extends CMSPageEditController {
|
||||
|
||||
public function doAdd($data, $form) {
|
||||
$className = isset($data['PageType']) ? $data['PageType'] : "Page";
|
||||
$parentMode = isset($data['ParentModeField']) ? $data['ParentModeField'] : "top";
|
||||
$parentID = isset($data['ParentID']) ? (int)$data['ParentID'] : 0;
|
||||
|
||||
if ($parentMode == "top") $parentID = 0;
|
||||
|
||||
$suffix = isset($data['Suffix']) ? "-" . $data['Suffix'] : null;
|
||||
|
||||
if(!$parentID && isset($data['Parent'])) {
|
||||
|
@ -25,6 +25,19 @@
|
||||
el.siblings().setSelected(false);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Reset the parent node selection if the type is
|
||||
* set back to "toplevel page", to avoid submitting inconsistent state.
|
||||
*/
|
||||
$(".cms-add-form .parent-mode :input").entwine({
|
||||
onclick: function(e) {
|
||||
if(this.val() == 'top') {
|
||||
var parentField = this.closest('form').find('#ParentID .TreeDropdownField');
|
||||
parentField.setValue('');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".cms-add-form").entwine({
|
||||
onmatch: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user