[1.0.x] Field Visibility Conditions

Created on 14 March 2025, 26 days ago

Field Visibility Conditions is a module that allows site builders (admins, or whomever has permission to configure fields) to use the core conditions plugin API to control whether entity form fields are visible on those forms or not. The benefit of this approach is for multi-sites, or shared codebase platforms, that share configuration across multiple sites but want some flexibility in control of what fields are present on forms. For example, if there are two sites sharing the same codebase, Site A and Site B, and only Site B needs a particular field on an entity type bundle, then using third party settings we are able to configure the visibility of that field based on a condition - this could be one provided by core, the contrib space, or something custom. This way both sites can still share the same configuration, as the third party settings are stored in config, but the conditions are evaluated per-site.

I have set up the code with GitlabCI for coding standards (Drupal and DrupalPractice), Linting, PHPStan, and Cspell checking, and there is kernel test coverage for the module functionality. Tugboat has also been configured to allow for merge request previews.

Project Link: https://www.drupal.org/project/field_visibility_conditions

📌 Task
Status

Needs review

Component

module

Created by

🇺🇸United States owenbush Denver, CO

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

Comments & Activities

  • Issue created by @owenbush
  • 🇪🇸Spain alvarodemendoza

    Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications , Application workflow , What to cover in an application review , and Tools to use for reviews .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues .

  • 🇪🇸Spain alvarodemendoza

    Coding Standards

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml field_visibility_conditions-1.0.x/*
    
    FILE: field_visibility_conditions-1.0.x/README.md
    -------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    -------------------------------------------------------------------------
      3 | WARNING | Line exceeds 80 characters; contains 101 characters
      7 | WARNING | Line exceeds 80 characters; contains 276 characters
     15 | WARNING | Line exceeds 80 characters; contains 96 characters
     29 | WARNING | Line exceeds 80 characters; contains 151 characters
    -------------------------------------------------------------------------
    
    
    FILE: field_visibility_conditions-1.0.x/tests/src/Kernel/FieldVisibilityConditionsTest.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     15 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormState.
    ---------------------------------------------------------------------------------------------------------------------
  • 🇺🇸United States owenbush Denver, CO

    Looks like my phpcs settings didn't pick up those issues, so thank you for that. I have updated the 1.0.x branch with changes to resolve those issues.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I would suggest enabling GitLab CI for the project and fix what it reports for PHP_CodeSniffer errors/warnings. Chances are that the reported errors/warnings will be different, but it is what GitLab CI reports that should be fixed.

  • 🇺🇸United States owenbush Denver, CO

    Thank you. I have got gitlab ci set up. It wasn't reporting any of the problems that were reported in this issue, but I resolved those anyway and the gitlab ci pipeline is green right now on 1.0.x

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    It does not report those issues because a custom phpcs.xml.dist file is used, and that does not use neither the Drupal ruleset nor the DrupalPractice ruleset.

  • 🇮🇳India vishal.kadam Mumbai

    1. FILE: README.md

    The README file is missing the required sections , including Installation, and Configuration.

    2. FILE: field_visibility_conditions.info.yml

    package: Custom

    This line is used by custom modules created for specific sites. It is not a package name used for projects hosted on drupal.org.

    3. FILE: field_visibility_conditions.module

    /**
     * @file
     * Primary module hooks for Field Visibility Conditions module.
     */

    Drupal does not have primary and secondary hooks. Instead of that, it is preferable to use the usual description: “Hook implementations for the [module name] module”, where [module name] is the name of the module given in its .info.yml file.

    /**
     * Implements hook_form_BASE_FORM_ID_alter().
     */
    function field_visibility_conditions_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {

    The description for that hook should also say for which form that hook is implemented, either by indicating that with the name of the class that implements the form (namespace included) or the form ID (which is usually indicated by getFormId()).

    4. FILE: src/FormAlters.php

      /**
       * Constructor for FormAlters.
       */
      public function __construct(

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be “Constructs a new [class name] object”, where [class name] includes the class namespace.

  • 🇺🇸United States owenbush Denver, CO

    Thank you for the review. I believe I have addressed the issues raised.

  • 🇮🇳India vishal.kadam Mumbai

    Rest looks fine to me.

    Let’s wait for a Code Review Administrator to take a look and if everything goes fine, you will get the role.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Thank you for your contribution and for your patience with the review process!

    I am going to update your account so you can opt into security advisory coverage any project you create, including the projects you already created.

    These are some recommended readings to help you with maintainership:

    You can find more contributors chatting on Slack or IRC in #drupal-contribute. So, come hang out and stay involved !
    Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review . I encourage you to learn more about that process and join the group of reviewers.

    I thank the dedicated reviewers as well.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024