"Enable extra settings" only allows for saving of "Pagination" and "Argument" options

Created on 10 November 2023, about 1 year ago
Updated 11 January 2024, 11 months ago

Problem/Motivation

I just updated to 2.0-beta7 in order to resolve a previously reported deprecation error and now I've found that my view reference field does not allow me to enable any extra settings save for Pagination and Argument. Consequently, the referenced view's title now displays across all of our existing references.

Currently on Drupal 10.1.4 with PHP 8.1 and find that the issue occurs across multiple sites.

Steps to reproduce

To verify that this was not an issue with Paragraphs (where our view reference field is normally situated), I created a new field in one of my existing content types and enabled all of the extra settings -- and then, after saving, only the Pagination and Argument options remained enabled (checked).

This how the field's config is set in the database (UUID and core hashes removed here for brevity):

field.field.paragraph.view_reference.field_view.yml

langcode: en
status: true
dependencies:
  config:
    - field.storage.paragraph.field_view
    - paragraphs.paragraphs_type.view_reference
  module:
    - viewsreference
id: paragraph.view_reference.field_view
field_name: field_view
entity_type: paragraph
bundle: view_reference
label: View
description: ''
required: true
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  handler: 'default:view'
  handler_settings:
    target_bundles: null
    auto_create: false
  plugin_types:
    block: block
  preselect_views:
    events: events
    news: news
    resources: resources
  enabled_settings:
    offset: 0
    pager: pager
    argument: argument
    title: true
    limit: 0
field_type: viewsreference
🐛 Bug report
Status

Closed: duplicate

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @c. s. comfort
  • 🇺🇸United States alison

    I'm experiencing this issue, too! -- updated viewsreference 2.0.0-beta6 => 2.0.0-beta7, and the only "extra settings" I can enable are Argument and Pagination. I checked on an environment that still has beta6, and on that environment, I can enable/disable all the "extra settings" checkboxes.

    • My field is a simple viewsreference field on a node, no Paragraphs involved.
    • I don't lose the other "extra settings" in the node edit form until I save the field settings -- until I save the field settings (and lose the "extra settings"), the "Include View Title" checkbox still still shows in the node form. (That said, I haven't tried enabling that checkbox to see if it "works" or if it's just "there" -- and I'm afraid at this point I just need to roll back the update and carry on with work, I can't do that test right now -- but I figured I'd at least share what I saw!)
    • I don't see anything in watchdog/drupal logs.

    FWIW, I'm still on Drupal 9.5.11 (PHP 8.1).

  • 🇫🇷France matoeil

    same same here

  • 🇩🇪Germany IT-Cru Munich

    Same here. After downgrade to 2.0.0-beta6 all is working fine for me again D10.1.

  • 🇪🇸Spain Carlitus

    Same, i need to enable "Limit results" but i cannot.

  • 🇮🇳India Shani Maurya Mumbai

    Same for me as well, I need to enable the "Include View Title" but It doesn't get enabled after checking the checkbox.

  • 🇫🇮Finland hartsak

    Yeah, I have exactly the same problem as #6.

  • 🇫🇮Finland hartsak

    Just adding some findings here after a quick debugging. Maybe these will help in solving the issue?
    In my case, it looks like the extra setting for "title" has been saved as a boolean value where the code assumes it is a string.

    For example from the config yml file of my "viewsreference" field:

    enabled_settings:
        argument: argument
        title: true
    

    In this example the argument works as expected, but the title doesn't.

    Because of that, in the node edit form, the "Include view title" field doesn't appear. The setting for the title doesn't get through in line 154 of file
    viewsreference/src/Plugin/Field/FieldWidget/ViewsReferenceTrait.php

    foreach ($enabled_settings as $enabled_setting) {
      if (!empty($plugin_definitions[$enabled_setting])) {
    

    In addition to that, the setting for title doesn't work when it is passed forward with the $enabled_settings in the file
    viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php

    $view->element['#viewsreference'] = [
      'data' => unserialize($item->getValue()['data'], ['allowed_classes' => FALSE]),
      'enabled_settings' => $enabled_settings,
      'parent_entity_type' => $parent_entity_type,
      'parent_entity_id' => $parent_entity_id,
      'parent_field_name' => $parent_field_name,
    ];
    

    Not sure yet how this could be fixed, as simply manually fixing the config file and doing a config import doesn't seem to help. I have added a quick hotfix that helps in my case, but this only helps with the symptoms not with the cause. So if others have the same issue too, you can try the hotfix but a proper fix would be better :)

  • First commit to issue fork.
  • Merge request !38Fix config schema. → (Open) created by arthur_lorenz
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    1 pass
  • Status changed to Needs review 12 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 12 months ago
    1 pass
  • 🇦🇹Austria arthur_lorenz Vienna

    The config schema for the field settings was off and expected integer values instead of strings. The config is saved using the option value instead of some integer/boolean, e.g.:

    enabled_settings:
        offset: 'offset'
        limit: 'limit'
    
  • Status changed to RTBC 12 months ago
  • 🇩🇪Germany hosterholz

    Merge request !38 solves the issue.

  • 🇪🇸Spain Carlitus

    For me still doesn't work. When enabled MR38 it works as before, when i submit the field edit form, only argument and pager can be enabled in Enable extra settings.

    In the config export i see this:

      enabled_settings:
        argument: argument
        limit: 0
        pager: pager
        offset: 0
    

    If i change to

      enabled_settings:
        argument: argument
        limit: 1
        pager: pager
        offset: 1
    

    and import the new config nothing happens, i don't see the limit and offset options in the entity where the field is included.

  • 🇦🇹Austria arthur_lorenz Vienna

    For me still doesn't work. When enabled MR38 it works as before, when i submit the field edit form, only argument and pager can be enabled in Enable extra settings.

    In the config export i see this:

    enabled_settings:
    argument: argument
    limit: 0
    pager: pager
    offset: 0

    Hmm, looks like the schema did not get updated. Did you clear the cache?

    If i change to

    enabled_settings:
    argument: argument
    limit: 1
    pager: pager
    offset: 1

    and import the new config nothing happens, i don't see the limit and offset options in the entity where the field is included.

    Of course, the value should match the key, as for argument and pager. So you'll need to change it to

      enabled_settings:
        argument: argument
        limit: limit
        pager: pager
        offset: offset
    
  • 🇪🇸Spain Carlitus

    I seem to have broken the first two laws of the drupal programmer:

    First law: Clear the cache
    Second law: If that doesn't work clear the cache again.

    And now it works, thank you very much

  • 🇦🇹Austria arthur_lorenz Vienna

    Fantastic :)

  • 🇺🇸United States rraney

    When I updated this module and upgraded to Drupal 10, all of my view blocks are now showing titles, whereas they previously did not. I think it might relate to this, since I cannot save the setting "Include View Title". Specifically, this is the case with blocks and view blocks. I'm not sure if it's related. I will try this hotfix, but if anyone has a suggestion, please share.

  • 🇦🇹Austria arthur_lorenz Vienna

    P.S. I applied this patch.

    You should've applied the patch from the referenced merge request :)

  • 🇺🇸United States rraney

    This is what I applied:
    "3400712: Enable extra settings only allows for saving of Pagination and Argument options" : " https://www.drupal.org/files/issues/2023-11-23/viewsreference-hotfix-ena... "

    Appears to be the same thing.

  • 🇺🇸United States rraney

    OK I've never merged from github, but I added .patch to the end and found this.
    https://git.drupalcode.org/project/viewsreference/-/merge_requests/38.patch

    I applied the patch. It worked

  • Status changed to Closed: duplicate 11 months ago
  • 🇦🇹Austria hudri Austria

    This is a duplicate of #3402036 🐛 Configuration schema for "Enable extra settings" (title,pagination,...) incorrect Fixed

    While both issues fix the problem, I don't the the solution proposed here is correct. IMHO the correct approach is the one from 3402036: Fix the type definition in the parent sequence, not change the value type of every single item ifself.

Production build 0.71.5 2024