Would be nice, if the settings could also be set in panels for each field pane. Sometimes this is working, but not always. For example on a taxonomy term reference field it does not work in panels (but in the manage display settings of the field it does).

Taxonomy module for example does not implement the hook_field_formatter_settings_form() (taxonomy_field_formatter_settings_form()). Ctools calls the settings forms (for panels) in ctools_fields_get_field_formatter_settings_form(), but actually only, if that function exists and without hook_field_formatter_settings_form there is no hook_field_formatter_settings_form_alter.

Should this module implement the hook_field_formatter_settings_form fore core modules? Maybe with the check if function_exists({$module}_field_formatter_settings_form)? Or should I do that in a custom module? Or should ctools call something like field_formatter_settings_field_formatter_settings_form() (if exists), in case hook_field_formatter_settings_form() is was not implemented?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

osopolar’s picture

Issue summary: View changes
osopolar’s picture

Issue summary: View changes
osopolar’s picture

Title: Panels Support » Panels Support for core-modules with no hook_field_formatter_settings_form() implementation
Issue summary: View changes
osopolar’s picture

Project: Field Delimiter (Multi Value Field Formatter) » Field formatter settings
Parent issue: » #1928054: Field formatter settings with CTool content_type entity_field plugin (Panels integration)
FileSize
0 bytes

I added link to parent issue: #1928054: Field formatter settings with CTool content_type entity_field plugin (Panels integration).

Invoking hook_field_formatter_settings_form_alter makes only sense, if the implementation $formatter['module'] . '_field_formatter_settings_form'; actually exists.

I added a patch for taxonomy_field_formatter_settings_form(). Would it be better to place it in a submodule of module Field Formatter Settings, so it could be enabled if necessary?

I am also wondering why drupal_alter('field_formatter_settings_form', $settings_form, $context); is only called on if ($settings_form): If a settings form has no setting, it could be altered anyway. Therefore I added a dummy setting to the form.

Edit: For the last part I created a ctools issue: #2537980: Alter field formatter settings even if settings form is empty

andrewmacpherson’s picture

@ospolar: thanks for moving this to the field_formatter_settings API module - I was just about to do so myself!

The patch in comment #4 is empty.

osopolar’s picture

Patch file with content.

osopolar’s picture

Status: Active » Needs review

As workaround I added the missing hook to a custom function. Are there any interests to add these functionality to Field formatter settings core?

// Enable field formatter settings support for core module taxonomy.
if (!function_exists('taxonomy_field_formatter_settings_form')) {
  function taxonomy_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
    // Form should not be empty, so we set a dummy value here.
    return array('#isset' => TRUE);
  }
}
Dave Reid’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm not sure why this is necessary to add here. Wouldn't this be a bug in CTools that it should alter even if there is no form callback, to allow other modules to add form elements?

osopolar’s picture

Status: Postponed (maintainer needs more info) » Needs review

I guess it's not a bug. If there is no form callback why should there be a form alter?

Check the linked issue, to see where and how ctools calls the form alter #2537980: Alter field formatter settings even if settings form is empty. It might be possible to call form alter without actually having a form callback - but it doesn't feel right, does it? ... If yes, then it may be enough to just change the ctools implementation.