When adding a field to a panel as a block, we are offered options for how to save settings for this field. These settings sometimes depend on the field instance settings, which is why $instance is passed into hook_field_formatter_settings_form() for field UI.

I'm using flexslider, and when setting the field settings via field UI everything works as expected. However, if I want to display this flexslider as a content pane in a panel the settings available to me on the panels-content-pane settings from are not correct.

Printing out $instance in hook_field_formatter_settings_form() reveals that the values are different whether in Field UI (where they are correct) or in the Panels UI (where they are incorrect).

I've tracked the problem down to ctools_fields_fake_field_instance() which is supposed to provide the instance settings needed for hook_field_formatter_settings_form() but gets them wrong. It looks like it's calling field_info_instance_settings which returns a field type's default instance settings, not the actual settings for the field.

In my case the DEFAULT settings for all fields of this type (provided by governing module), and the ACTUAL settings for this particular field (provided by user, in UI) are different.

It looks like ctools should be using field_info_instances() to get the ACTUAL settings for each field. That function requires both the entity type and the bundle, so those would need to be passed into ctools_fields_fake_field_instance.

I'm a little lost as to how to get the entity and bundle I am editing from this part of the code. I know they should be present because they are a required context for this pane, but... where?

edit: I should also state that this was working in previous versions of ctools - though I think 2 versions ago. (hence why major). After upgrading, field panes lost their settings.

Comments

jenlampton created an issue. See original summary.

jenlampton’s picture

Issue summary: View changes
jenlampton’s picture

Issue summary: View changes
jenlampton’s picture

Category: Bug report » Support request
Priority: Major » Normal

Oh, I think I see now. We can't assume a particular bundle because this pane could be placed for multiple types!

Does that mean the only way to display a field-with-instance-specific settings is to build a single-field view? Actually, I wonder if views has the same problem... checking...

jenlampton’s picture

Views seems to get it right, even when there is more than one node type in the filters. Not sure how, but could be worth looking into.

jenlampton’s picture

Status: Active » Closed (fixed)

Okay, so I've got some ctools specific code in the field module now (see #1645100: Add caption support for ALT to FlexSlider Fields). Not sure if that's the only way to solve this, but closing this support request since I've at least got it working. :)