sleeping-owl / admin

Administrative interface builder for Laravel
http://sleeping-owl.github.io/
MIT License
503 stars 260 forks source link

Invalid redirection url #339

Open b4rtaz opened 8 years ago

b4rtaz commented 8 years ago

Hello!

When i am saving form then i am redirected to invalid address.

Example: admin/model_name//edit

Url doesn't has id, because my model doesn't has column 'id'.

Bellow code is current (AdminController.php):

if ($nextAction == 'save_and_continue') {
    $response = redirect()->to($model->getEditUrl($createForm->getModel()->id));
}

Bellow fix:

if ($nextAction == 'save_and_continue') {
    $newModel = $createForm->getModel();
    $primaryKey = $newModel->getKeyName();
    $response = redirect()->to($model->getEditUrl($newModel->{$primaryKey}));
}

Regards.