Problem/Motivation

While it appears as though the Administer -> Reports -> Field list hasn't turned into a view yet (I'm assuming this is non-trivial given that there's no native support for creating a view of fields), we should still find a way to make it more usable, whether we do this through Views or not.

For example, I'd like to be able to do the following:

  • Sort by field type.
  • Filter by field type.
  • Increase the number of items on each page.

I found a contrib module that looks like it handles the filtering: Filter Field List

Proposed resolution

Creating a form with two filters by entity_type and field_type.

Remaining tasks

Write patch
Code review
A11Y review
UX Review
Commit

User interface changes

Added two select lists, Entity type and Field type on the admin/reports/fields page
Screenshot of fields

API changes

None

Data model changes

None

CommentFileSizeAuthor
#56 Screenshot 2023-01-30 at 18.03.53.jpg253.31 KBmarkconroy
#56 Screenshot 2023-01-30 at 18.03.37.jpg151.39 KBmarkconroy
#47 After--patch--pic.png44.25 KBvikashsoni
#47 before--patch--pic.png50.08 KBvikashsoni
#43 interdiff_39-42.txt2.29 KBraman.b
#43 2959299-43.patch10.12 KBraman.b
#40 after--patch.jpg243.77 KBranjith_kumar_k_u
#40 before---patch.jpg356.42 KBranjith_kumar_k_u
#39 interdiff_36-39.txt2.5 KBraman.b
#39 2959299-39.patch10 KBraman.b
#36 2959299-36.patch9.72 KBHardik_Patel_12
#34 2959299-34.patch9.71 KBjungle
#33 field_ui-exposed-filters-after-patch.png120.86 KBVinodhini.E
#27 field_ui-add-exposed-filters-2959299-27.patch9.97 KBartemboiko
#26 interdiff.txt14.56 KBartemboiko
#19 Screen Shot 2019-06-21 at 14.44.27.png111.1 KBartemboiko
#17 interdiff-2959299-14-17.txt1.49 KBartemboiko
#17 field_ui-add-exposed-filters-2959299-17.patch9.54 KBartemboiko
#5 field_ui-add-exposed-filters-2959299-5.patch7.74 KBartemboiko
#8 field_ui-add-exposed-filters-2959299-8.patch7.61 KBartemboiko
#10 field_ui-add-exposed-filters-2959299-10.patch7.61 KBartemboiko
#13 interdiff-2959299-5-8.txt4.1 KBvoleger
#13 interdiff-2959299-8-10.txt854 bytesvoleger
#14 interdiff_10-14.txt1.67 KBartemboiko
#14 field_ui-add-exposed-filters-2959299-14.patch9.46 KBartemboiko

Issue fork drupal-2959299

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colan created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

colan’s picture

joshua.boltz’s picture

Every time I use the field report, I think to myself exactly this issue. Glad it’s in the works.

artemboiko’s picture

I have added filters for entity type and field type. I tried to add sorting functionality in getEntityIds() of FieldStorageConfigListBuilder but seems like QueryInterface tableSort doesn't work with this type of entities.

artemboiko’s picture

Status: Active » Needs review

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

artemboiko’s picture

Previous patch is wrong.
I have fixed it and updated it to the latest version of core 8.8.x-dev

andypost’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs change record
artemboiko’s picture

I have added new patch with small fixes of code standards.

@andypost could you clarify what should be done in scope of tag needs change record ?

colan’s picture

Please provide interdiffs to make it easier for reviewers.

andypost’s picture

@artemboiko That's a way to announce changes https://www.drupal.org/contributor-tasks/draft-change-record
So when patch commited everyone will get notification

Also more about tags you can find in Issue tags description in sidebar block about issue state

voleger’s picture

Interdiffs for:

  1. #5 and #8
  2. #8 and #10
artemboiko’s picture

Thanx @voleger.

I've updated tests for checking that two form elements with needed options are exist. And I've added code for testing submit form and filtering of results. Also, I've created change record.
Pls review @andypost @colan.

What is the next step?

artemboiko’s picture

voleger’s picture

  1. +++ b/core/modules/field_ui/src/Form/FieldConfigListForm.php
    @@ -0,0 +1,182 @@
    +  /**
    +   * Build entity types options for select list.
    +   *
    +   * @param array $fieldStorageConfigs
    +   *   The array of field storage configs.
    +   *
    +   * @return array
    +   *   The array of options.
    +   */
    

    To improve DX change the type of the parameter from the array to <ProperInterface>[].
    Also, update return type of the method from array to string[] to show the type of the elements of the array.

  2. +++ b/core/modules/field_ui/src/FieldStorageConfigListBuilder.php
    @@ -136,4 +136,50 @@ class FieldStorageConfigListBuilder extends ConfigEntityListBuilder {
    +  /**
    +   * Loads entity IDs using a pager sorted by the entity id.
    +   *
    +   * @return array
    +   *   An array of entity IDs.
    +   */
    

    The same as 1.

  3. +++ b/core/modules/field_ui/src/Form/FieldConfigListForm.php
    @@ -0,0 +1,182 @@
    +  /**
    +   * Build field types options for select list.
    +   *
    +   * @param array $fieldStorageConfigs
    +   *   The array of field storage configs.
    +   *
    +   * @return array
    +   *   The array of options.
    +   */
    

    The same as 1.

artemboiko’s picture

Thanx @voleger.
Added this changes.

artemboiko’s picture

Issue summary: View changes
artemboiko’s picture

Issue summary: View changes
FileSize
111.1 KB
artemboiko’s picture

Issue summary: View changes
voleger’s picture

Status: Needs work » Reviewed & tested by the community

Much better, set to RTBC

colan’s picture

Status: Reviewed & tested by the community » Needs work

Just catching up on this now, sorry.

Wouldn't it be better to turn this page into a view? I believe all we've done here is hard-code the additional functionality instead of:

  1. Exposing this stuff to Views, and
  2. Providing a view with this functionality as the default (allowing users to change it from the view configuration).

...just like the Users page (except that we have to add the first step above because these aren't entities).

artemboiko’s picture

@colan
Yes It would be great and I investigated it.

But views designed to work with entities and their database table. I mean user entity has it’s own table in db. In our case field_storage_config is stored in one table with other configs. So for implementing it with views we need to write tons of harcode. And I am not sure that it will work right.

Correct me if I am wrong.

andypost’s picture

@colan Nice idea, there was 2 attempts to add additional backends for config entities
- https://www.drupal.org/project/efq_views
- https://www.drupal.org/project/config_views

Sadly both looks forgotten so at this stage we can just improve UI a bit by hardcoding filters into list builder

  1. +++ b/core/modules/field_ui/field_ui.routing.yml
    @@ -1,7 +1,7 @@
    -    _entity_list: 'field_storage_config'
    +    _form: '\Drupal\field_ui\Form\FieldConfigListForm'
    

    in summary not clear why list_builder no longer used and new form object added

  2. +++ b/core/modules/field_ui/src/Form/FieldConfigListForm.php
    @@ -0,0 +1,182 @@
    + * Implements an example form.
    ...
    +class FieldConfigListForm extends FormBase {
    

    docs

  3. +++ b/core/modules/field_ui/src/Form/FieldConfigListForm.php
    @@ -0,0 +1,182 @@
    +  public function getFormId() {
    +    return 'field_config_list_form';
    

    why it is not list builder like "draggable" one we have for vocabularies

colan’s picture

Well, thanks for looking into it. Yes, let's just continue with what we're doing here.

artemboiko’s picture

FileSize
14.56 KB

@andypost please check, I have added form to the list_builder.

artemboiko’s picture

andypost’s picture

Status: Needs work » Needs review

Looks great, but now a question of tests!
Views integration needs separate issue, I bet one exists in efq/config-views contrib

artemboiko’s picture

idebr’s picture

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

couloir007’s picture

Has anyone applied this to 8.8?

Vinodhini.E’s picture

I have applied patch #17, It's working for me.
I am attaching a screenshot after applying a patch.

jungle’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Hardik_Patel_12’s picture

FileSize
9.72 KB

Re-rolling patch against 9.1.x-dev , kindly review a patch.

Status: Needs review » Needs work

The last submitted patch, 36: 2959299-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

raman.b’s picture

Status: Needs work » Needs review
FileSize
10 KB
2.5 KB

Another re-roll. Also addressing failed test cases, handling deprecations and fixing some CS issues

ranjith_kumar_k_u’s picture

FileSize
356.42 KB
243.77 KB

The above patch works fine ,it creates two select box filters Entity type , Field type and also the filters works fine.
Before patch
before patch

After patch
after patch
RTBC

ranjith_kumar_k_u’s picture

Status: Needs review » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Needs work

#39 is still failing tests.

We should open a follow-up for views support and conversion, looks like https://www.drupal.org/project/config_views has some work towards this.

raman.b’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Bohus Ulrych’s picture

FYI I was not able to use patch #43 with D9.2.1
Composer failed with
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-12-18/2959299-43.patch

Then I tried to patch it manually:
patching file core/modules/field_ui/src/FieldStorageConfigListBuilder.php
Hunk #4 succeeded at 90 with fuzz 2 (offset 2 lines).
Hunk #5 succeeded at 113 (offset 2 lines).
Hunk #6 succeeded at 193 (offset 2 lines).
patching file core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
Hunk #1 FAILED at 752.
1 out of 1 hunk FAILED -- saving rejects to file core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php.rej

Thanks

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

vikashsoni’s picture

Applied patch #10 working fine and applied successfully
After patch file exposed filters added successfully
Thanks for the patch ....

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ifrik’s picture

Patch #43 fails to apply for Drupal 10.1.x

ifrik’s picture

ifrik’s picture

Status: Needs work » Needs review
ifrik’s picture

This might not be as configurable as a view would be, but it will already help a lot with sitebuilding and with checking module upgrades, by reducing the very long list of fields on more complex sites.

This page is not used by content editor etc. on a production site, but purely a reference used in the development and maintenance of the site, so adding these filters is not breaking any customized functionality.

smustgrave’s picture

@vikashsoni why did you test #10?

Seems issue is being addressed in MR but have CI failures

Hiding files to avoid confusion and noise.

markconroy’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
151.39 KB
253.31 KB

This is looking good to me and works as expected, however I don't know enough to mark it RTBC.

With the latest commit passing, I'll set it to needs review for now.

Before:

before

After:

after

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs change record updates

Left some comments on the MR.

Also the CR will need some updates.

Added tests for form elements and filtering functionality by submit of form.

don't think that needs to be included in the CR.

CR doesn't mention the new parameter needed.

CR could use some before/after screenshots.

ifrik’s picture

I'm happy to continue working on this. But what is "CR"?

andypost’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.