Part of #2557113: Make t() return a TranslationWrapper object to remove reliance on a static, unpredictable safe list

The options for the text area are not properly set. $options['content'] and $options['format'] should be $options['content']['value'] and $options['content']['format']

Beta evaluation

Part of a major issue, where this is causing test fails as we're setting $options['content'] to be an object, so reading from $options['content']['format'] fatals

Comments

stefan.r created an issue. See original summary.

stefan.r’s picture

Status: Active » Needs review
stefan.r’s picture

StatusFileSize
new2.94 KB
stefan.r’s picture

Issue tags: -Needs tests
stefan.r’s picture

StatusFileSize
new2.96 KB
stefan.r’s picture

Title: Fix contents of options array in pre-render function for "input required" exposed form plugin » "Text on demand" for "input required" exposed form plugin is not displayed
Issue summary: View changes
joelpittet’s picture

+++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
@@ -182,6 +182,18 @@ public function testInputRequired() {
     $this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply'));
...
     $rows = $this->xpath("//div[contains(@class, 'views-row')]");
     $this->assertEqual(count($rows), 0, 'No rows are displayed by default when no input is provided.');

Looks like this is interrupting an existing test. Maybe it needs it's own test method?

joelpittet’s picture

StatusFileSize
new3.01 KB

Moved it into it's own test method. @stefan.r can you boil off any crud in that test that isn't needed as I expect you know what you are testing (I'm only guessing)

joelpittet’s picture

+++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
@@ -81,8 +84,13 @@ public function preRender($values) {
+        // We will display this message even if the view has no result.
+        'empty' => TRUE,

Is this needed as well?

The last submitted patch, 4: 2561273-4.patch, failed testing.

The last submitted patch, 6: 2561273-6.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 9: text_on_demand_for-2561273-9.patch, failed testing.

stefan.r’s picture

Well I was also wondering about that. The view in the test had no result, so it was only "needed" to test for the string there :)

We could also rewrite the test to actually have results...

Considering this is a text that is used to convey to the user that an exposed filter is required, I am a bit unclear about whether to set it to true by default (which would mean the text will display even if the view has no results).

This is something that has been in views since #535868: Exposed forms as plugins, so I'll see about having a look at that issue and installing an old version of views to find out how this used to behave on no results.

stefan.r’s picture

From digging into the original D6 code it looks like passing along the empty=TRUE option is indeed needed. That old code had the 1 of the 2 bugs this patch found (back then it was indeed $options['content'] and $options['format']), but there was no way to make it work because empty option was not set back then either, so it this 'feature' may have been broken for 6+ years? :)

Basically in the query() method the InputRequired exposed form plugin forces an empty result if no exposed filters are applied.

The "on demand text" (that used to have as default "Select any filter and click on Apply to see results") will only display if no exposed filters are applied (see InputRequired::preRender()).

But the views area text handler will only render something if either the empty option is enabled ("Display even if view has no result") or if the result is not empty. As the result is always empty, and the empty option is disabled, the text never shows. So I believe we need to set this option here.

I'd also be fine with removing the whole "on demand text" feature, if it never even worked?

stefan.r’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB
stefan.r’s picture

StatusFileSize
new3.47 KB
dawehner’s picture

  1. +++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
    @@ -81,14 +84,22 @@ public function preRender($values) {
    +        // We need to set the "Display even if view has no result" option to
    +        // to TRUE as the input required exposed form plugin will always force
    +        // an empty result if no exposed filters are applied.
    +        'empty' => TRUE,
    

    Could and helpful explanation!

  2. +++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
    @@ -81,14 +84,22 @@ public function preRender($values) {
    +      // Override the existing empty result message (if applicable).
           $this->displayHandler->setOption('empty', array('text' => $options));
    

    Just a general question, do we really want to override all other existing ones, don't we want to append just?

stefan.r’s picture

Issue summary: View changes

updating IS

stefan.r’s picture

Hmm if we appended we'd need to worry about separators / wrapping them in different HTML elements, and in this case the view isn't actually empty, it's just "fake empty" (the input required plugin does this). So the empty message may or may not be correct -- if applicable, it will currently show up as soon as an exposed filter is selected and the view is still empty. So I think we're fine here and in any case this sounds a bit out of scope for this issue. May be follow-up material as this whole feature is confusing, I don't think "Text on demand" is a thing in English anyway? :P

The last submitted patch, 16: 2561273-testonly.patch, failed testing.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Has tests, improves docs, helps unblock our TranslatedString issue. All goodness.

stefan.r’s picture

StatusFileSize
new159.79 KB
new162.56 KB

And screenshots:

stefan.r’s picture

  1. +++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php
    @@ -81,14 +84,22 @@ public function preRender($values) {
    +        // We need to set the "Display even if view has no result" option to
    +        // to TRUE as the input required exposed form plugin will always force
    

    "to to", can be fixed on commit

  2. +++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
    @@ -194,6 +194,31 @@ public function testInputRequired() {
    +    // Ensure that the "on demand text" is not displayed when an exposed filters
    

    s/filters/filter/

joelpittet’s picture

StatusFileSize
new1.82 KB
new3.47 KB

Fixing the comment nits in #24

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c3c61bc and pushed to 8.0.x. Thanks!

  • alexpott committed c3c61bc on 8.0.x
    Issue #2561273 by stefan.r, joelpittet: "Text on demand" for "input...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.