SleepingOwlAdmin
SleepingOwlAdmin copied to clipboard
Redirect after saving
I'm trying to redirect to a specific route after model saving? After model A is saved, I would like to redirect to Model B edit form.
I'm working on the model A method
public function save(array $options = array())
is it the right way?
I remember that the form buttons could have a a callback, but can't find any reference in the code or documentation
Thanks, CS
FormButton setUrl
method is working for SaveAndClose and Save buttons. It does not work for Cancel button, this is because class Cancel has a URL in "initialize" method.
I add buttons using this code:
$form->getButtons()->setButtons([
'save_and_close' => (new SaveAndClose())->setUrl('myURL')->setText ('Save and go to new URL'),
'cancel' => (new Cancel())->setUrl('myURL')->setText ('Cancel and go to new URL'),
'save' => (new Save())
]);
Solved using a customized button instead of cancel
$button->setName('cancel');
$button->setText('Cancel');
$button->setUrl($url);
$button->setHtmlAttributes($button->getHtmlAttributes() + [
'class' => 'btn btn-warning',
]);
$form->getButtons()->setButtons([
$button
]);
Is it possible that save and close does not fire "Save" event? The redirect url works, but data are not saved
Using "setUrl" for buttons the default action is not fired, it behaves as a link. Is it a bug ?
https://github.com/LaravelRUS/SleepingOwlAdmin/blob/development/resources/views/default/form/button.blade.php#L6