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:
Ingo Schommer 2012-05-07 14:30:08 +02:00
parent 1fa54abf6c
commit 6ec6b107ca
2 changed files with 13 additions and 3 deletions

View File

@ -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'])) {

View File

@ -26,6 +26,19 @@
}
});
/**
* 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() {
var self = this;