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

HansKuiters created an issue. See original summary.

HansKuiters’s picture

Title: On multiple availability calendar fields on a content type, uncheck box should remove field » On multiple availability calendar fields on a content type, uncheck box should remove field instance
Issue summary: View changes
fietserwin’s picture

Title: On multiple availability calendar fields on a content type, uncheck box should remove field instance » Unable to remove an availability calendar field value instance
Version: 7.x-5.6 » 7.x-5.x-dev

The "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.

HansKuiters’s picture

Thanks 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.

HansKuiters’s picture

Solved 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.

fietserwin’s picture

Category: Bug report » Feature request
Status: Active » Closed (won't fix)

I'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).