tobimori / kirby-dreamform

✨ DreamForm is an opiniated form builder plugin for Kirby CMS that makes forms work like magic
https://plugins.andkindness.com/dreamform
45 stars 7 forks source link

Referer Page is not found when there is custom page url #102

Open lemmon opened 5 days ago

lemmon commented 5 days ago

I have page with custom masked url:

public function url($options = null): string
{
    return $this->parent()->url() . '/' . $this->title()->slug() . '/' . $this->uid();
}

In such case findRefererPage() is not able to find referer page. I see two options: A) Iterate over all of the pages and match url with http referer url (probably far from efficient approach) or B) Insert referer page uuid within submitted form data. The later might resolve #101 too.

tobimori commented 5 days ago

This is a tricky one.

I decided to use the referer URL, because the form should work on any rendered route (in case you don't have the #101 issue) - if we use the page UID there might be issues where the redirect does not work, e.g. when you have a param attached to the URL or you simply use a route to render the page (where most people don't override the url()).

I figured it would be perfectly fine if the Referer Page is empty, it's only used in the Email action anyway.

tobimori commented 5 days ago

Generally I avoid routes in my projects where I use a custom URL like that (e.g. vierbeinerinnot.de) - instead I use virtual pages, since there are other Kirby plugins such as Staticache incompatible with routes as well.

lemmon commented 5 days ago

Yes, I agree. I tend not to use custom urls as well. But when client asks... you know how that goes.