When choosing the "expert template" in manage display, and typing in a custom class, the value is never rendered in the field output. The custom changes are not being saved.

Additionally, if one goes back to edit the original settings, manage display does not remember the previous custom changes. When clicking on the "edit gear" the template always changes back to "default" and any custom settings are forgotten.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zoon_unit created an issue. See original summary.

aspilicious’s picture

I have tests for this, and I can't reproduce this problem.
I'm not sure how to move forward without additional bug reports.

zoon_unit’s picture

Not sure how I can clarify the issue. Here's some more info:

The first image, "display_ste_expert_1.jpg" shows that display suite has remembered part of the prior setting. It shows that the expert template was previously chosen. But when I click on the edit gear, image2 shows that the expert template choice is forgotten. The setting reverts back to the default template.

At first, I thought the settings I made previously were being saved, but that the edit form was failing to initiate the saved values from the database when going in to edit, but after further testing, I can confirm that the expert template settings I'm putting in are not saved at all.

If you look at my original image up top, you'll see that I'm trying to attach a css class to the notes field. But after putting in the values, pressing the update button, and then saving changes on the "manage display" screen, the values are not saved. (the "excerpt-note" class is not added to the field)

Is it possible that the field update button is not properly saving the values to the database? It's obviously saving the value of "expert" somewhere, but none of the actual changes I made to the field. Then, whenever you press the edit gear, ALL values are reinitialized as default values.

Is that any clearer? The field in question, "notes" is a long text field, if that helps.

zoon_unit’s picture

FileSize
86.93 KB

Also, the inability to save changes affects more than the expert template. I tried adding my css class to Display Suite's "field CSS" box, and then adding the class using the default template. (see image)

That value was not saved either, even though the css class DID show up on the edit form.

default template

aspilicious’s picture

When choosing expert template and add a css class, you ALWAYS need to choose the element.
Than it will save. (normally)

aspilicious’s picture

Title: Field template settings not applied or remembered » CSS field classes are not merged with default template

Your last report is a true bug.
This lacks a test.

zoon_unit’s picture

FileSize
89.93 KB

@aspilicious, not sure I understand this statement: "When choosing expert template and add a css class, you ALWAYS need to choose the element. Than it will save. (normally)"

I tried that, and the error persists. The template always goes back to "default" and never saves the value.

Might want to revert back to the original issue title . . .

default template

aspilicious’s picture

It's strange because I have more than 40 tests to proove this actually works.
Can you try with other fields?

zoon_unit’s picture

@aspilicious, I've tried several different fields and content types, including Drupal 8's article content type, and I can never get the field to remember the setting. The class is never inserted in the html output either.

I've also tried entering "manage display" from "admin/structure/ds" as well as from "admin/structure/types/manage/content_type/display." I'm using display suite 2.3 and layout plugin alpha 22. It's a pretty basic Drupal 8 site.

Here are the other modules I have installed: ctools alpha 23, entity api alpha1, inline entity form alpha 5, pathauto alpha 2, token alpha 2.

That's it. Any chance there could be a conflict with one of these other modules?

I would also recommend renaming the title of the issue, as the "non-saving" behavior is the same for both the expert and default templates. This does not look like two different issues to me.

zoon_unit’s picture

I tried installing the display suite dev version from Mar. 10, but that didn't fix anything. So I uninstalled display suite, display suite extras, and display suite switch view mode and tried reinstalling ds 2.3.

I now get the following error:

Unable to install Display Suite Extras, core.entity_view_mode.node.revision already exists in active configuration.

zoon_unit’s picture

Title: CSS field classes are not merged with default template » Field template settings not applied or remembered
zoon_unit’s picture

@aspilicious, I've now tested Display Suite on both a Linux and Windows system, and the bug behavior is the same. In both cases, however, I'm using php 5.5. Could it be possible that when you are testing, that you are using a different version of php? Could this have any affect on behavior?

It's just a stab in the dark . . .

mike_pol’s picture

@zoon_unit I can confirm that I have exactly the same problem. It is not PHP 5.5 related, as I have 5.6 installed on my dev machine and 5.5 on production.

@aspilicious This is tested on drupal 8.1.0, PHP 5.6.14, DS version: 8.x-2.3. Here is what happens when you try to save field display:
I only have the ds and layout_plugin enabled
Video of the issue

I am seeing exactly what was described in #3. There are no PHP errors/warnings/notices and no console errors. I can see the ajax post and it includes the submitted values where you would expect them.

aspilicious’s picture

Thank you for the video.
I looked at it several times before I noticed something.

There isn't a layout selected.

So there is a bug as you shouldn't be able to select a template when DS isn't active....
Can someone confirms this is the actual issue?

mike_pol’s picture

I can confirm that indeed this was the issue. As I wasn't familiar at all with the DS module this was hard for me to understand that I needed to apply a layout first before. As you said, after selecting a layout it all worked fine.

aspilicious’s picture

Title: Field template settings not applied or remembered » Hide field template forms when no display is selected
Issue tags: +Needs tests
scoff’s picture

I'm not sure it's related, but here's what I see
Latest DS dev (May 06) ds_extras disabled

Manage display

Image field, widget is "Image style: Medium (220×220) Field template: expert"
but if I click the cog I get "Choose a Field Template: Default" selected. This value is actually anything I set as "Default Field Template" at /admin/structure/ds/settings
If the default is Expert I get a nice expert form and it's empty.

Setting it back to expert and filling all the needed fields again actually does work - settings are applied and I can see the result, but changing anything is pain.

It works as expected for some fields. The Image above is actually a default Media thumbnail (it's not a field you can edit). Some other Image fields work fine. Media name is plain text and it doesn't work also but some plain text fields work.

Never works: Language code field, Media bundle: Name (test), Thumbnail(image), Created (date) etc. Custom fields seem to work.
Some fields work if the DS Layout is set and don't work otherwise. Some never work. Some work even if the Layout is none.

zoon_unit’s picture

@aspilicous, @mike_pol, that is great news that it's just a layout issue! Like mike_pol, I'm not familiar enough with display suite functionality to understand the need for a layout prior to using a template. (why is that, precisely?) Mystery solved. However, I might suggest a couple of different ways to address this problem. One obvious solution would be to provide more comprehensive help with display suite that lays out the basic paradigm of its use, because much of DS functionality is not obvious to the first time user.

Another suggestion would be to throw an error on the template selection (field edit) page to remind users to set the layout first, rather than simply turning off template functionality. That way, you would be teaching the new user how to use display suite properly. Simply making the templates unavailable without a layout would leave the new user scratching his head as to what is wrong. Having researched the issue, I now realize that on the manage display page at the bottom, where one chooses the layout, it clearly states "A layout must be selected to enable Display Suite functionality." HOWEVER, it is so easy for a newbie to miss that when setting things up.

FWIW, I find that so many issues on modules are due to "user error" ie. not understanding how a module is intended to be used. As a professional writer, I'd like the emphasize that perhaps more time should be spent by module programmers in either documentation, or "self teaching" UI design. They would then reduce their issue burden significantly. Just a thought.

Thanks for ferreting out this problem, guys!

aspilicious’s picture

Well... there are video's for DS. Did you watch them?

ozin’s picture

Status: Active » Needs review
FileSize
3.04 KB

Hi guys,
I've created patch to fix this issue. Please check if I did not miss something.

I used different entities to get layout settings into summary because I get fatal error when I call $field->getTargetEntityTypeId(); in case when the foem_state is not set. Not sure why it caused fatal. Perhaps you guys have some ideas how to improve this.
Error message:
Fatal error: Call to undefined method Drupal\ds\Plugin\DsField\User\User::getTargetEntityTypeId() in /var/www/drupal8/modules/ds/ds.module on line 777

scoff’s picture

@ozin

Trying to 'manage display' of a media bundle, ds layout is enabled, patch #20 applied

Fatal error: Call to a member function getThirdPartySetting() on boolean in /.../modules/ds/ds.module on line 791

This returns NULL

$bundle = $field->getTargetBundle();

And then this returns FALSE

$entity_display = Ds::getDisplay($entity_type, $bundle, $view_mode);

Tested also on nodes and paragraphs, same result.

ozin’s picture

Fixed fatal error, but there are another bug with entity fields. Need to figure out how to get the EntityDisplay for object in the ds_field_formatter_settings_summary_alter when field is as entity field(line 784).

Status: Needs review » Needs work

The last submitted patch, 22: ds_hide-field-template-2679785-2.patch, failed testing.

The last submitted patch, 22: ds_hide-field-template-2679785-2.patch, failed testing.

The last submitted patch, 22: ds_hide-field-template-2679785-2.patch, failed testing.

swentel’s picture

Version: 8.x-2.3 » 5.0.x-dev
swentel’s picture

swentel’s picture

Version: 5.0.x-dev » 8.x-3.x-dev

not sure if we are able to fix that, but let's try

swentel’s picture

Status: Needs work » Needs review
FileSize
3.07 KB

Seems to do the trick

  • swentel committed de04bc69 on 8.x-3.x
    Issue #2679785 by ozin, swentel: Hide field template forms when no...
swentel’s picture

Status: Needs review » Fixed
swentel’s picture

Status: Fixed » Closed (fixed)
swentel’s picture

Status: Closed (fixed) » Needs work

re-opening, the behavior without lb makes it crash and let's also check how core is hiding the cog when fields are in the disabled area

  • swentel committed 83fcba08 on 8.x-3.x
    Issue #2679785: add after build function
    
swentel’s picture

Status: Needs work » Fixed

Ok, this is done

swentel’s picture

Status: Fixed » Closed (fixed)