I like to use the preset attribute in the fields.yaml
preset:
field: name
type: slug
prefixInput: id
I would like to preset the slug field with a slug which is a combination from ID and title.
So for id 1 and title “This is my title”, I would like to preset “1-this-is-my-title”
This approach has a slight problem; the preset JS library is often used when creating a record, so the ID will be unavailable.
Secondly, if we include composite field support, there would need to be an ID field which might look unsightly.
A good pattern is to let the slug be the same and include the ID in the URL, like this
/:slug/:id
Lookup the record using the ID and the slug is just a facade for SEO purposes. You can also redirect any slug and this is even better for SEO, so when the slug changes links are never broken.
each time i got this discussion, every time i got an flashing light in my mind, because i work for high secure company and this is bit or less, always a exposing any type of incrementing value that can bring potential risk… of course, if ID is uuid, then this is out of topic, but, regarding example, simple integer value is always something, what is flagged as potential risk.