Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have multiple availability calendar fields on a content type and "allowed values" is unlimited. If I occasionally or by accident add another item but don't want to use it, or I just want to remove an instance of that field, unchecking the box "Enable the availability calendar" should remove the availability calendar field instance. It doesn't. Is this a bug, a feature request or inherited from core fields behaviour?
Comments
Comment #2
HansKuiters CreditAttribution: HansKuiters commentedComment #3
fietserwinThe "enable" checkbox is a value that is part of the AC field, not Drupal fields in general. It was introduced for the use case where multiple resource owners are listed on a site but not all of them want to go through the effort of keeping the availability up to date. So unchecking won't remove that field value instance.
Removing a field value is normally done by emptying it after which the hook_field_is_empty() function should return TRUE and the value will be removed from the database. Unfortunately this field was designed as to never be considered empty, so at this moment it is not possible to delete a field value via the editor UI.
Solving this will require an explicit delete button similar to the image field. However, as consequences may be far reaching (much further then deleting an image which normally can be easily re-uploaded) that button should get a separate confirmation step (what to do with other changes to the entity?) and it should be possible for site builders to disable the delete button like they already can disable the "Enable" checkbox.
If you are interested, give it a go. I will help and review where requested. But from the above it should be clear that it won't be straightforward.
Comment #4
HansKuiters CreditAttribution: HansKuiters commentedThanks for your reply. As it is not straightforward and I'm my skills as a programmer are not that good, I won't give it a go. I'll see what I can do for now by making the name field required and in the frontend check for a value in there to show or hide it.
Comment #5
HansKuiters CreditAttribution: HansKuiters commentedSolved it for now. In this project for each item I needed a AC field I allready had a fieldcollection field. So I added the AC field to the fieldcollection and I only need one instance there.
Comment #6
fietserwinI'm not going to implement this anymore. Patches are welcome, but be warned that it won't be simple to create a good one (that is, a patch that considers all of the above remarks).