Summary

The "Use image title as the caption" checkbox is disabled when using the flexslider field formatter in Views and Panels, and cannot be enabled.

A help message states "You need to enable the Title field for this image to be able to use it as a caption", but the enable link leads to a non-existant page:
admin/structure/types/manage/ctools/fields/field_foo

This error is displayed even if the Title field is already enabled for the field.

Cause

The $instance array passed to the field formatter settings form does not have the ['settings']['title_field'] value set correctly.

Original report

Hi,
when I add a flexslider field in a pane and select flexslider formatter, I'm unable to check the "Use image title as the caption". It's grey/muted. Also, the link in "You need to enable the Title field for this image field to be able use it as a caption." lead to a non existent page: admin/structure/types/manage/ctools/fields/field_galleria_immagini?destination=admin/structure/types/manage/ctools/display#edit-instance-settings-title-field
Of course, the Title and Alt subfields for the flexslider field are enabled.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kojo Unsui’s picture

I don't know exactly why this succeeds with Panels. But having the same disabled checkbox, I solved it altering the Formatter styles form :

<?php
/**
 * Implements hook_form_FORM_ID_alter().
 */
function YOUR_MODULE_form_ctools_entity_field_content_type_formatter_styles_alter(&$form, &$form_state, $form_id) {
  $form['caption']['#disabled'] = FALSE;
} 
?>
JKingsnorth’s picture

Title: "Use image title as the caption" checkbox muted in panels » "Use image title as the caption" checkbox disabled in panels and views
Issue summary: View changes

Following up from jastraat's comment in #1861524: Add options for displaying title text on images as caption in FlexSlider Fields and my own experience, the checkbox also doesn't work in Views. I've updated the issue summary to account for this.

JKingsnorth’s picture

Assigned: Unassigned » JKingsnorth

I'll do some work on this today.

JKingsnorth’s picture

Assigned: JKingsnorth » Unassigned
Issue summary: View changes
FileSize
1.9 KB
1.1 KB

The field formatter in flexslider_fields.module checks to see if the $instance['settings']['title_field'] is set. It disables the checkbox if it isn't.

The $instance is passed in to the field formatter settings form.

However, in Views the $instance array does not have the title_field and alt_field values set correctly - see the outputs attached. So this looks like an error in ctools / Views rather than Flexslider itself: the settings are not picked up correctly.

Perhaps something with a better knowledge of Views / ctools would be able to pick this up and maybe open an issue in the relevant issue queue?

JKingsnorth’s picture

Status: Active » Needs review
Issue tags: -panels
FileSize
678 bytes

Digging further: the instance used in Views and Panels is set by the ctools_fields_fake_field_instance function (in ctools\includes\fields.inc).

This function sets the 'settings' to be the default settings for the image field - rather than the settings for that field on a particular content type. So because the title_field is not set by default on the 'image' field type, 0 is returned.

Since ctools doesn't know the context of the field instance (ie: what content type the field is attached to) then we will not be able to check whether the field is set in this way.

So my proposed solution is to not check whether or not the field is enabled when access the formatter via a ctools form (Views, Panels...). The check can remain when setting up the formatter anywhere else (such as via 'Manage display').

This also fixes the fact that the links to enable the field point to a non-existent page from Views, because the message will not be displayed.

Patch attached!

ckrina’s picture

The patch from #5 applies and it solved the disabled check problem in Panels for 2.x-dev. Thanks!

Maybe another review to set RTBC.

Ether’s picture

Will this patch be implemented in dev version ? Have this problem with last dev version.

JKingsnorth’s picture

Hi Ether, if you can confirm that the patch works then let us know and we can probably mark this as reviewed and tested. Then it is more likely to get picked up and implemented.

Ether’s picture

Patch works when applied to the last dev version.

JKingsnorth’s picture

Status: Needs review » Reviewed & tested by the community

RTBC then =] Thanks!

minorOffense’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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