area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.77k stars 576 forks source link

Permalink while editing title is different than the permalink shown in the admin #2516

Open Tofandel opened 8 months ago

Tofandel commented 8 months ago

Description

I want to hide the language in the permalink of the admin interface only for the default language (which I think is a common use case)

So I provide something like this according to https://twillcms.com/docs/modules/controllers.html

protected function formData($request): array
    {
        return parent::formData($request) + [
            'localizedCustomPermalink' => [
                config('app.locale') => route('partners.details', Partner::find($request->route('partner')))
            ]
        ];
    }

Which shows correctly here image image

But shows wrong information while editing image

And prevents the configured custom permalink from updating on the page once it's been saved

It seems a different approach is needed for this to work, I'm thinking something like:

protected function formData($request): array
    {
        return parent::formData($request) + [
            'localizedCustomPermalink' => [
                config('app.locale') => route('partners.details', '{slug}')
            ]
        ];
    }

Maybe provided outside of formData as well that we could correctly use and replace in both places