Skip to content

Commit

Permalink
Merge pull request #124 from Kunstmaan/fix_add_new_pagepart
Browse files Browse the repository at this point in the history
fix: when adding a new pagepart with invalid fields, the pageparts was moved outside the page region
  • Loading branch information
Wim Vandersmissen committed Sep 4, 2014
2 parents bc0626e + 5da5029 commit 58622b7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PagePartAdmin/PagePartAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,28 @@ public function preBindRequest(Request $request)
// Create the objects for the new pageparts
$this->newPageParts = array();
$newRefIds = $request->get($this->context . '_new');

if (is_array($newRefIds)) {
foreach ($newRefIds as $newId) {
$type = $request->get($this->context . '_type_' . $newId);
$this->newPageParts[$newId] = new $type();
}
}

// Sort pageparts again
$sequences = $request->get($this->context . '_sequence');
if (!is_null($sequences)) {
$tempPageparts = $this->pageParts;
$this->pageParts = array();
foreach ($sequences as $sequence) {
if (array_key_exists($sequence, $this->newPageParts)) {
$this->pageParts[$sequence] = $this->newPageParts[$sequence];
} else {
$this->pageParts[$sequence] = $tempPageparts[$sequence];
}
}
unset($tempPageparts);
}
}

/**
Expand Down

0 comments on commit 58622b7

Please sign in to comment.