[Missing docs] Slugs and slugAttributes #860
Unanswered
henze-housepedia
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Bumping this issue It's still not possible to have the permalink update correctly if there is multiple fields The following create form with the previously mentionned workaround <x-twill::input
name="first_name"
:label="twillTrans('speaker.first_name')"
:translated="$translateTitle ?? false"
:required="true"
on-change="formatPermalink"
/>
<x-twill::input
name="last_name"
:label="twillTrans('speaker.last_name')"
:translated="$translateTitle ?? false"
:required="true"
on-change="formatPermalink"
/>
@if ($permalink ?? true)
<x-twill::input
name="slug"
:label="twillTrans('twill::lang.modal.permalink-field')"
:translated="true"
ref="permalink"
:prefix="$permalinkPrefix ?? ''"
/>
@endif Any change to any field will trigger the permalink to be set to this field, we need to be able to send params to |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It seems straightforward, but when you need a concatenation of a string it is not. When you want to make a concatenation of an id and a title, you might think: "Hey, this $slugAttributes is an array of column names. I just do the following":
public $slugAttributes = [ 'id', 'title', ];
Right? Wrong! the first is being used for the slug. The rest is used for dependencies. I don't know what this means, but it breaks if the columns aren't in the slugs table.
If you need a concatenation of two strings, just do the following:
`public $slugAttributes = [
'slugifyThis',
];
This does only work when not using translations. If you need translations to work, I suggest a rewrite of the getSlugParams. (create your own trait, use HasSlug {getSlugParams as public getTwillSlugParams;} )
This does nothing with the permalink, as this is being generated client side, and there are NO options to alter it's behavior, so advice is to turn permalinks off or deal with the fact that it does not show you what it is going to be.
As for the dependency thing, @ifox?
Beta Was this translation helpful? Give feedback.
All reactions