Moving "feeds item" field in form display to non-disabled causes PHP error

Created on 26 September 2023, over 1 year ago
Updated 28 February 2024, 11 months ago

Problem/Motivation

It would be nice to have some debugging information available relative to feeds information stored in "feeds item" field, if anything is even stored there.

Steps to reproduce

-Navigate to feed item form display (structure/types/manage/YOUR_FEED_NAME_HERE/form-display)
-Scroll down to disabled at the bottom, note the "Feeds item" field, with an empty drop down.
-Drag the "feeds item" field up into the active fields section of the tabledrag.
-Submit, and note PHP error:
Drupal Component Plugin Exception PluginNotFoundException: The "hidden" plugin does not exist. Valid plugin IDs for Drupal\Core Field) WidgetPluginManager are: (etc etc)

Screenshots


Proposed resolution

Establish a feeds item form widget. Ideally if possible have it display useful information to users with the permissions "Administer Feeds"

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jnicola

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

Comments & Activities

  • Issue created by @jnicola
  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    Attaching a patch version of my initial work from that fork incase folks want to grab this in such a fashion.

    All I did was add a field widget. No display handling. I left a TODO in there to eventually display useful debug information for admins, if that's what even is contained in that field?

    This no matter what alleviates fatal errors relating to trying to drag that field into form display though!

  • πŸ‡΅πŸ‡ΉPortugal lolgm

    @jnicola Thanks for the patch.

    This problem makes it impossible to translate form display configurations of entities that have the Feeds Item field.
    For more detailed information, I explained in comment #282
    #2546212-282: Entity view/form mode formatter/widget settings have no translation UI β†’

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 11 months ago
    Composer require-dev failure
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 11 months ago
    716 pass
  • πŸ‡³πŸ‡±Netherlands megachriz

    A feeds_item field wasn't mean to appear on the "Manage form display" page

    The field type "feeds_item" has a "no_ui" property set to TRUE in its annotation. According to \Drupal\Core\Field\Annotation\FieldType that means:

    /**
     * A boolean stating that fields of this type cannot be created through the UI.
     *
     * @var bool
     */
    public $no_ui = FALSE;
    

    So I assume this should mean that the field isn't supposed to appear on the "Manage form display" page. Could this perhaps be a bug in Drupal Core? Or did I misunderstood the purpose of the "no_ui" property here?
    In Drupal Core, the following field types also have "no_ui" set: "changed", "created", "language", "map", "password", "uri" and "uuid". Some do have a default widget, but not all of them. At least some of these field types I don't see either on "Manage form display", like "uuid". So why is it that an "uuid" field on an entity does not cause trouble, but a "feeds_item" field does?

    Commit patch as is?

    Anyway, I see that the field is displayed on the "Manage form display". So maybe we should commit this patch as is (if it doesn't break any tests). I wasn't aware that it could cause trouble. Thought it was only a minor UX issue when accidentally dragging the field on the form display.

    What a feeds_item field contains

    I left a TODO in there to eventually display useful debug information for admins, if that's what even is contained in that field?

    A feeds item field contains metadata about the imported entity. It tells when the entity was imported, with which feed entity it was imported and it has a hash value that is used by Feeds to determime if the source item has changed on a subsequent import. The properties "guid" and "url" can be mapped to. Perhaps it is useful to make these two properties editable with a widget.

  • πŸ‡΅πŸ‡ΉPortugal lolgm

    no_ui property

    From what I can see, the no_ui property in the field annotation is only used to prevent this from being listed when creating a new field in entities (/admin/config/people/accounts/fields/add-field).

    Field form display configuration

    The only way I know to prevent a field from appearing in the form's display list is to define the entity's base fields.
    Eg. bellow: Defining the fields of the Feed entity (feeds_feed), if I didn't want the title field to be displayed in the form display setDisplayConfigurable('form', FALSE)
    https://git.drupalcode.org/project/feeds/-/blob/8.x-3.x/src/Entity/Feed....

    /**
      * {@heritdoc}
      */
    public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
      $fields = [];
      ...
      $fields['title'] = BaseFieldDefinition::create('string')
       ->setLabel(t('Title'))
       ->setDescription(t('The title of this feed, always treated as plain text without markup.'))
       ->setRequired(TRUE)
       ->setDefaultValue('')
       ->setSetting('max_length', 255)
       ->setDisplayOptions('display', [
         'label' => 'hidden',
         'type' => 'string',
           'weight' => -5,
         ])
         ->setDisplayOptions('form', [
           'type' => 'string_textfield',
           'weight' => -5,
         ])
         ->setDisplayConfigurable('form', FALSE);
         ...
    } 
    

    That being said, it is completely useless in this case...

    Feeds item widget

    Although I don't see any use case where the feeds item field would be exposed, I think it would be the simplest solution.
    Since this field stores internal feed processing information, would it be a good solution to have a readonly option in the widget?

    @MegaChriz Thanks for the quick help.

Production build 0.71.5 2024