Skip to content
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

Redirects issues #7

Open
ing-edgar opened this issue Nov 1, 2023 · 1 comment
Open

Redirects issues #7

ing-edgar opened this issue Nov 1, 2023 · 1 comment

Comments

@ing-edgar
Copy link

Hi there,

The issue occurs when performing redirects. After saving a resource and then redirecting, it only displays a blank modal. I don't know why.

This code works if I don't use route.post(url, model);

` public function actionCreate()
{
$model = new ThirdParty();

    if ($this->request->isPost) {
        if ($model->load($this->request->post()) && $model->save()) {

            return $this->redirect(['index']);
        }
    }
    //dd("redirect");
    return $this->inertia('ThirdParty/Create');
}

`
Any idea why?

thanks.

Captura desde 2023-10-31 21-35-50

@ing-edgar
Copy link
Author

So far, the only solution I've found for the redirection issue is the following:

public function actionCreate()
{
    $model = new ThirdParty();

    if ($this->request->isPost) {
        if ($model->load($this->request->post())) {
            return $this->response->redirect(['ecommerce/third'], 302, checkAjax: false);
        }
    }
    //dd("redirect");
    return $this->inertia('ThirdParty/Create');
}

This code is used to handle the creation of a resource in an application and address issues related to redirection within the context of Inertia.js. The key here is that the AJAX validation is being turned off in the redirection by using checkAjax: false to ensure that the redirection works correctly with Inertia.js.

If someone finds a better solution, I would appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant