New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Data objects] Default value generator service for URL Slugs #6132
Comments
@weisswurstkanone @BlackbitNeueMedien: I just tested this feature and I'm not sure if I'm getting this right (No specific documentation about this). This will trigger ( Imagine a customer wants to create a blog entry - the (localized) title is available after an update because it's not possible to add those fields in an object creation state... I came up with a proposal some years ago (#1048) and I think that's still a thing. The slug field is an "unsuable" field in a business point of view, since a user needs to add a complete path to it ( |
I have not retested it now but as I remember I tried to implement it so that the default values are generated every time an object gets saved if the field is empty. This is done in pimcore/models/DataObject/Concrete/Dao.php Lines 245 to 264 in 7669a92
For example for the pimcore/models/DataObject/ClassDefinition/Data/Input.php Lines 119 to 124 in 7669a92
The handleDefaultValue() then returns the default value if the field is empty.
Sadly |
UrlSlugThis pimcore/models/DataObject/ClassDefinition/Data/UrlSlug.php Lines 243 to 251 in 1f9d0ff
Also, the method Handle Default ValueThis method does not get dispatched in update processes: pimcore/models/DataObject/Traits/DefaultValueTrait.php Lines 52 to 57 in 672b674
|
UrlSlug uses the CustomResourcePersistingInterface (not the ResourcePersistenceAwareInterface) so there is no getDataForResource. |
Hmm, does a default value generator make any sense then for URL slug datatype, @weisswurstkanone ? Because - as @solverat said - originally default value generators had two intentions:
Imho, with the current implementation URL slugs can only fulfill 1. but not 2. |
Currently not, but the goal should be to make sense ;) URL Slugs is something a user will never manually input, so it has to be generated somehow. |
I just stumbled upon this issue while trying to figure it out myself, and in the end I opted for a calculated data type. The benefit is that it runs on every save, but the downside is that the user can't manually edit the slug, which in my experience, they do want the option to do. A workaround for that would be to have a second input field where they can manually enter a slug, but that isn't very nice. Anyway, just thought I'd leave this here for anyone else who stumbles across the issue. |
as an addition to #5069
The text was updated successfully, but these errors were encountered: