Bug #89560
closedInputSlugElement cannot use 'uid' for slug suggestion Ajax request
100%
Description
When we have a slug field that is defined to use the uid and e.g. the name of a record for generating a slug, the refresh button does not work.
Example TCA configuration:
'slug' => [
'label' => 'slug',
'config' => [
'type' => 'slug',
'size' => 128,
'generatorOptions' => [
'fields' => ['name', 'uid'],
'fieldSeparator' => '-',
'replacements' => [
'/' => '-'
],
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInPid',
'default' => ''
]
]
This configuration is valid and produces the correct result when the slug field is cleared and automatically filled by the DataHandler upon saving.
Using the refresh button does not work however. The SlugElement TS/JS searches for FormEngine input fields and adds the values of those to its request.
The uid however is not a FormEngine input field and therefore cannot be read and added to the fields that are used to generate the slug.
Two workarounds are known. But they come with lots of problems.
1.
Telling editors to clear the field instead of using the refresh button (as they are used to from pages).
This works but is a burden upon the editors and there will surely be some who use the refresh button anyway, resulting in "wrong"/inconsistent slugs.
2.
Adding the uid as a FormEngine input field. This allows the SlugElement.ts/js to read the uid value, as long as it is not set to read only.
Even when hidden by put into a hidden palette, it can still be manipulated and break everything.
Of course the SlugElement.ts/js does know about the uid, so it should be a simple thing to add it to the values sent to the FormSlugAjaxController.