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?
Comment | File | Size | Author |
---|---|---|---|
#6 | field_formatter_settings-implement-core-hooks-2536026-5.patch | 740 bytes | osopolar |
Comments
Comment #1
osopolarComment #2
osopolarComment #3
osopolarComment #4
osopolarI 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 whydrupal_alter('field_formatter_settings_form', $settings_form, $context);
is only called onif ($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
Comment #5
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer commented@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.
Comment #6
osopolarPatch file with content.
Comment #7
osopolarAs workaround I added the missing hook to a custom function. Are there any interests to add these functionality to Field formatter settings core?
Comment #8
Dave ReidI'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?
Comment #9
osopolarI 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.