Compare commits

...

2 Commits

Author SHA1 Message Date
Niklas Forsdahl a9b0a70155 Throw 404 error on grid field nested form move-to-parent action,
if no record is found.
2024-05-07 18:20:56 +03:00
Niklas Forsdahl 8f505659f0 Only add nested form to nested gridfield child if that child is of
the same class as the parent record.
2024-05-07 18:02:06 +03:00
2 changed files with 2 additions and 2 deletions

View File

@ -288,7 +288,7 @@ class GridFieldNestedForm extends AbstractGridFieldComponent implements
$list = $gridField->getList();
$id = isset($move['id']) ? (int) $move['id'] : null;
if (!$id) {
throw new HTTPResponse_Exception('Missing ID', 400);
throw new HTTPResponse_Exception('Missing ID', 404);
}
$to = isset($move['parent']) ? (int)$move['parent'] : null;
// should be possible either on parent or child grid field, or nested grid field from parent

View File

@ -73,7 +73,7 @@ class GridFieldNestedFormItemRequest extends GridFieldDetailForm_ItemRequest
}
}
if ($this->record->hasExtension(Hierarchy::class)) {
if ($this->record->hasExtension(Hierarchy::class) && $relationClass == get_class($this->record)) {
$config->addComponent($nestedForm = new GridFieldNestedForm(), GridFieldOrderableRows::class);
// use max nesting level from parent component
$nestedForm->setMaxNestingLevel($this->component->getMaxNestingLevel());