New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overlapping props and redirect to base route from controller #47
Comments
It's worth to note that the redirect works correctly in this way. So in above example, you are starting from Option 1 would be to instead of going Option 2 avoids this problem, if you specify the redirect action Option 3 is a bit more cumbersome, but works a treat. You can capture the redirect target in the session in the controller when hitting class ContactsController {
public function edit(Request $request) {
session()->put('modal-referer', $request->headers->get('referer'));
// ...
}
public function update() {
// ...
return redirect()->to(session('modal-referer'))->with('success', 'Contact updated');
}
} const { show, close, redirect } = useModal();
const submit = () => form.clearErrors() && form.put(route('contacts.update'), {onSuccess: close}); This latter approach will take you back to the page from which you have triggered the modal window and will also ensure you are going forward in history, so updates appear as expected. (Note that if you are using pagination as a component, you might need to add the |
I'm very much liking this package and have successfully implemented except for a few issues.
The first issue is that I'm having to name the form used in the modal differently to an existing form in the base route.
For example, let's say I have an organisation and a contact with the
name
attribute. When opening the contacts modal, thename
seems to be overwritten (at least initially) with thename
attribute from the base organisation. I fixed this issue by renaming theform
for the contacts modal tocontactForm
but I'm wondering why it the occurs in the first place.The second issue is that I would like to redirect to the previous base route (not the default one) when updated. Doing the following in keeps the modal open:
Is there anyway of determining what the current base route is so I can redirect to it without having to close the modal from the frontend?
I did see some responses in #29 that may help with this...
The text was updated successfully, but these errors were encountered: