Insert implements hook_field_widget_info_alter() to add Insert-specific settings to all fields in the system that can be inserted, regardless of whether the insert feature is enabled on those fields.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m.stenta’s picture

Oops. False alarm. You can actually revert the Features... but it still would be nice to ONLY add the insert settings to a field if insert is enabled.

m.stenta’s picture

Title: Overrides all Features containing insert-able fields » Only add insert settings to insert-enabled fields
Issue summary: View changes
Status: Active » Closed (works as designed)

Closing this... I'll open a new ticket if it makes sense to do what I described in my first comment. But maybe it's not necessary...

m.stenta’s picture

Category: Feature request » Task
Status: Closed (works as designed) » Active

Actually, I was wrong (again)... you CANNOT revert these Features. So to reiterate (since I removed this from the original issue description):

"Unfortunately, if you have a field in a Features module that does not have insert enabled on it, that Feature always appears as overridden, even if you "revert" it manually. This is due to the hook_field_widget_info_alter() adding it to the field array.

It's possible to simply add these blank, disabled insert options to the Feature module code, and then it does not appear as "overridden". But ultimately, this isn't always possible (if you're using someone else's Feature, for instance, and they don't use Insert)."

m.stenta’s picture

Status: Active » Needs review
FileSize
1.46 KB

Attached is a patch which allows overridden Features to be reverted.

Basically, what it does is simply get rid of hook_field_widget_info_alter(), and instead saves field Insert settings to an entity type only when it is saved in the admin UI. Doing so causes any Feature with that field to appear overridden (because it will have the Insert settings included), BUT because it's no longer using hook_field_widget_info_alter(), it's possible to revert the overridden Feature.

It doesn't solve the ultimate goal of only saving the settings if Insert is enabled, but it's a step in that direction.

Snater’s picture

Browsing through old tickets while working on the module's D8 version. This is a reasonable change. I tweaked it a little bit an will merge it into the repo, unless there is any objection.
I assume preventing saving the settings at all when Insert is disabled, could be done by attaching a #validate callback to the form in insert_form_field_ui_field_edit_form_alter. But I guess the intention would be to also remove (reset) all Insert settings when disabling Insert, which is probably not what I would expect from a user perspective when just unticking the Enable Insert checkbox.

  • Snater committed f5c468e on 7.x-1.x
    Issue #2285995: Removed storing settings using...
Snater’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.