Skip to content
Browse files

Pass id of containing form through to popup

  • Loading branch information...
1 parent 0dccea3 commit 3c33e68269e249090862099c9345faf5774e9f97 @sergei-matheson sergei-matheson committed Oct 17, 2011
Showing with 30 additions and 2 deletions.
  1. +30 −2 code/DataObjectManager.php
View
32 code/DataObjectManager.php
@@ -333,6 +333,27 @@ function saveComplexTableField($data, $form, $params) {
}
/**
+ * Called to preselect, both in the database and on the form, the given $child.
+ * @param unknown_type $childData
+ * @param unknown_type $form
+ */
+ protected function selectChild($childData, $form) {
+ $this->controller->{$this->Name()}()->add($childData);
+ if (isset($_REQUEST['DataObjectManagerId'])) {
+ $id = $_REQUEST['DataObjectManagerId'];
+ $childId = $childData->ID;
+ $form->addSessionJs(
+<<<EOF
+(function() {
+var list = top.jQuery("#{$id}_CheckedList");
+list.val(list.val()+'$childId,');
+})();
+EOF
+);
+ }
+ }
+
+ /**
* Called after a complex field is save
* @param DataObject $childData
* @param unknown_type $data
@@ -474,7 +495,7 @@ public function PaginatedLink()
}
public function AddLink() {
- return Controller::join_links($this->BaseLink(), 'add');
+ return Controller::join_links($this->BaseLink(), 'add', '?DataObjectManagerId='.$this->id());
}
public function ShowAll()
@@ -858,8 +879,15 @@ function __construct($controller, $name, $fields, $validator, $readonly, $dataOb
Requirements::javascript('dataobject_manager/javascript/dom_jquery_ui.js');
Requirements::javascript('dataobject_manager/javascript/tooltip.js');
Requirements::javascript('dataobject_manager/javascript/dataobject_manager.js');
- }
+ }
$this->NestedController = $this->controller->isNested;
+ //Add the DataObjectManagerId to the form as a hidden input, if present.
+ if (isset($_REQUEST['DataObjectManagerId'])) {
+ $this->fields->push(
+ new HiddenField('DataObjectManagerId', null, $_REQUEST['DataObjectManagerId'])
+ );
+ }
+
}
function FieldHolder() {

0 comments on commit 3c33e68

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