NumericFilter incorrectly expects to find form value keyed by 'value'

Created on 22 January 2016, about 9 years ago
Updated 8 April 2025, 9 days ago

Problem/Motivation

Views filter plugins have a public "value" property in which values for a plugin can be injected. The form generated by this plugin can be quite nuanced and in some cases includes a separate 'value' form element, but all exposed forms are keyed by 'value' normaly so this is then ['value']['value']. While this is ok, that form element finds its default value in $this->value['value'], however this appears to have been copied over to the normal 'value' form element (which is produced in a different configuration circumstance). This is invalid as exposed forms are converted from the 'value' key to an $identifier key outside of this method before the form is rendered. Because of this, the exposed form's values will be submitted as that identifier. If a contrib module attempts to save that value, it can't properly inject it back into all views filter plugins because numeric's handling of this is wrong and affects all subclasses (date at the very least).

Proposed resolution

Set the default value by looking at $this->value[$identifier] instead

Remaining tasks

TBD

User interface changes

If anything this should cause certain situations in which submitted values might have disappeared to start working.

API changes

None

Data model changes

None

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡ΊπŸ‡ΈUnited States eclipsegc

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Is this still a problem?

    I tested the patch on 11.x and the results was Warning: Undefined array key "field_number_value" in Drupal\views\Plugin\views\filter\NumericFilter->valueForm() (line 271 of core/modules/views/src/Plugin/views/filter/NumericFilter.php).. I don't know Views well enough to take this further.

    Can someone confirm that this problem is still valid?

    I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Production build 0.71.5 2024