When editing a field of type "iframe" in admin/structure/types/manage/..., default values are not saved. So when creating a new node with a field of type "iframe", the default values are not used. I don't know if this is the same issue, but the configuration for the frameborder and scrolling attributes are ignored in nodes.

Comments

LpSolit created an issue. See original summary.

marcvangend’s picture

Any news on this? I'm seeing the same thing: the frameborder is rendered even though I configured the field with "no frameborder". It looks like the configuration is stored correctly though, because in the field config yml (field.field.paragraph.iframe.field_iframe.yml in my case) it says frameborder: '0'. I wonder if IframeDefaultFormatter::iframe_iframe() is doing its job properly.

marcvangend’s picture

Indeed, the frameborder disappears when you change this...

    if (!empty($item->frameborder) && $item->frameborder > 0) {
        $options['frameborder'] = (int)$item->frameborder;
    }

...to this...

    $options['frameborder'] = $item->getValue('values')['frameborder'];

...around line 131 of iframe/src/Plugin/Field/FieldFormatter/IframeDefaultFormatter.php. I have no time to write a patch at the moment, but it looks like the module can use a bit of cleaning up.

neffets’s picture

Assigned: Unassigned » neffets

Can you verify that you mean the manage/ page?

Please try dev-version:
On my page "/admin/structure/types/manage/story/fields/node.story.field_iframe9" I can save and change the "frameborder", the scrolling", and so on. It remembers all changes and shows me the changed setting on reedit.

What is Your setting at:
* /admin/structure/types/manage/story/fields/node.story.field_iframe9
* and manage form display /admin/structure/types/manage/story/form-display on iframe-field behind "wheel"

marcvangend’s picture

In fact, I tested this on the /admin/structure/types/manage/page/fields/node.page.field_iframe_test page (node field configuration form), as well as the /admin/structure/paragraphs_type/iframe/fields/paragraph.iframe.field_iframe page (paragraph field configuration form). Both behaved the same.

I updated to the dev version (commit 11a5ae0) but that didn't solve the problem. The change described in #3 does work. I guess you always have to define $options['frameborder'], even if it is 0, to make sure the frameBorder attribute is set on the iframe element.

I tested this with Drupal 8.2.6, in both Firefox and Chrome.

marcvangend’s picture

It turns out it's more complicated than I thought. When you change the frameborder field setting after content has been saved, the value of $item->frameborder remains the same. I guess that is what LpSolit meant when he wrote that the default value is not saved. (It is in fact saved, but not used.)

I give up, I'll just use CSS instead.

rafaelcaceres’s picture

I confirm this. I can't apply a scrolling="no" to my ifram!

doxigo’s picture

The same problem with Width and Height default values

ankithashetty’s picture

Facing problems in saving default values like height, width here... Any idea how to fix this?

neffets’s picture

Version: 8.x-1.6 » 8.x-1.x-dev
Status: Active » Needs review

test again.

  • neffets committed 8b8813d on 8.x-1.x
    Issue #2852581 - FieldType fielSettingsForm fixed, it saves now all...

  • 92e5824 committed on 8.x-1.x
    Issue #2852581 by neffets: Default values for fields of type "iframe"...

  • neffets committed 1ea9c93 on 8.x-2.x
    Issue #2852581 by neffets: Default values for fields of type iframe are...
neffets’s picture

Added "massageFormValues()" function which acts as "presave" Function.

Problem was, that the user are only allowed to save some attributes (title, width, height)
The admin-values (frameborder, etc) are not saved and were not available to node-rendering of the iframe-field.

Now the user-values will be enhanced by the admin-values before saving.

neffets’s picture

Version: 8.x-1.x-dev » 8.x-1.13
Status: Needs review » Fixed
neffets’s picture

Version: 8.x-1.13 » 8.x-1.x-dev

Status: Fixed » Closed (fixed)

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