Problem/Motivation

Exposed forms in Views may be set to "Input required" so that results are only shown when at least one filter is selected.
Since this setting might affect logic in other places (like filter options handling), so it would be handy to determine whether this setting is active. Moreover, the Better Exposed Filters module extends the InputRequired class, but adds another similar setting.

Proposed resolution

Add an isInputRequired() public method to ExposedFormPluginInterface and implement it in core implementations (classes ExposedFormPluginBase and InputRequired).

User interface changes

None.

API changes

See above.

Release notes snippet

Issue fork drupal-3300701

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:

Comments

mrshowerman created an issue. See original summary.

mrshowerman’s picture

Version: 9.5.x-dev » 9.4.x-dev
Assigned: mrshowerman » Unassigned
Status: Active » Needs review
StatusFileSize
new1.73 KB
mrshowerman’s picture

StatusFileSize
new1.73 KB
mrshowerman’s picture

StatusFileSize
new1.73 KB
smustgrave’s picture

Status: Needs review » Needs work

Looks like patch #4 failed to apply. Moving back to NW

mrshowerman’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.74 KB

There was a name clash with between the inputRequired() method and the InputRequired class.
Renamed the method to isInputRequired().

smustgrave’s picture

Since this is a feature request it may not need a test case but won’t be surprised if it is requested.

lendude’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Not sure about needing this, since it's using a specific plugin class I would just do $plugin instanceof InputRequired, but ¯\_(ツ)_/¯

And yes it does need tests (it doesn't need a test-only patch for features)

mrshowerman’s picture

The idea of providing a method for it came from the fact that Better Exposed Filters is sub-classing InputRequired while adding a custom setting that controls whether input is really required or not. So simply checking for $plugin instanceof InputRequired wouldn't return the correct result when said setting is set to false.
Of course, one could argue why on earth there can be cases where an InputRequired subclass may not require input. But in my opinion it's a much easier solution than rewriting Better Exposed Filter's plugin.

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new722 bytes
new2.6 KB

Uploaded a simple assertion.

smustgrave’s picture

Version: 9.4.x-dev » 10.1.x-dev
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.86 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mrshowerman’s picture

Status: Needs work » Needs review
StatusFileSize
new2.6 KB
new901 bytes

Fixed {@inheritdoc} syntax.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

Self review.

It will need change record for new functions

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record +Needs Review Queue Initiative

Added a simple change record.

Think I'm good to review this ticket as my contribution was the tests and not the actual fix.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3300701-13.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Seems to be random failure. Restarted tests.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 3300701-13.patch, failed testing. View results

mrshowerman’s picture

Status: Needs work » Reviewed & tested by the community

I guess it's a random failure again. Re-started tests.

catch’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review

@lendude wasn't convinced about this before, so moving back for subsystem maintainer review again.

smustgrave’s picture

Status: Needs review » Needs work

Brought this up in #needs-review-queue-initiative channel and seem we may need a new solution. Was pointed out #9 says this could be done in contrib technically. Reason that this must live in core?

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.

smustgrave’s picture

@lendude blast from the past. Wonder if #9 answers your question?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.