I followed the example from here: https://octobercms.com/docs/backend/reorder
And this is my table where i have menu categories with subcategories:
And it works fine. My records are sortable but when I tried to update some record which is main record(parent_id is null) then I have this error:
"Cannot resolve target node." on line 927...
This is from:
protected function validateMove($node, $target, $position)
{
if (!$node->exists)
throw new Exception('A new node cannot be moved.');
if (!in_array($position, ['child', 'left', 'right'])) {
throw new Exception(sprintf(
'Position should be either child, left, right. Supplied position is "%s".', $position
));
}
if ($target === null) {
if ($position == 'left' || $position == 'right') {
throw new Exception(sprintf(
'Cannot resolve target node. This node cannot move any further to the %s.', $position
));
}
else {
throw new Exception('Cannot resolve target node.');
//there i have this error when i tried to update record with parent_id = null
}
}
if ($node == $target) {
throw new Exception('A node cannot be moved to itself.');
}
if ($target->isInsideSubtree($node)) {
throw new Exception('A node cannot be moved to a descendant of itself.');
}
return !(
$this->getPrimaryBoundary($node, $target, $position) == $node->getRight() ||
$this->getPrimaryBoundary($node, $target, $position) == $node->getLeft()
);
}
When I create new menu element or update element which have parent_id I havent problem only when I tried to update. Maybe someone can see where can i make mistake.
