Skip to content
Browse files

BUGFIX Don't require ParentModeField in CMSpageAddController submissi…

…ons, to allow for easier programmatical submission of "add page" form (via CMS tree). Reset any selected parent nodes in the interface instead
  • Loading branch information...
1 parent 1fa54ab commit 6ec6b107cae5cd7bdaad79c6768fa5c2f29704f6 @chillu chillu committed May 7, 2012
Showing with 13 additions and 3 deletions.
  1. +0 −3 code/controllers/CMSPageAddController.php
  2. +13 −0 javascript/CMSMain.AddForm.js
View
3 code/controllers/CMSPageAddController.php
@@ -97,11 +97,8 @@ function AddForm() {
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
13 javascript/CMSMain.AddForm.js
@@ -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() {

0 comments on commit 6ec6b10

Please sign in to comment.
Something went wrong with that request. Please try again.