SOLVED: Search form label - accessibility

Bricks Version: 1.5.7
Browser: Chrome 90
OS: macOS / Windows / Linux / etc.
URL: (a link to a page that illustrates the issue would be really helpful)

to comply accessibility <label tag needs a for=“”

I changed the code in searchfield.php to work proprely as follows (BOLD):

<label **for="search_field"** class="screen-reader-text"><span><?php esc_html_e( 'Search ...', 'bricks' ); ?></span></label>
<input type="search" placeholder="<?php esc_attr_e( $search_text ); ?>" value="<?php echo get_search_query(); ?>" name="s" **id="search_field"** />
2 Likes

Hi Varga,
Thanks so much for your report, and welcome to the forum!

I’ve added your suggestion to the to-do list :slight_smile:

Best regards,
timmse

Hi Varga,
We’ve fixed this bug in Bricks 1.6.1, now available as a one-click update within your WordPress Dashboard.

Please let us know if you are still experiencing issues.

Best regards,
timmse

I just updated to Bricks 1.6.1 and when in a page there is a “Search Field” I get this error:

This is the 404 page that contains the search field under the title.
I also get this error in Admin widget page, where there are the search field.
Any idea?
Thanks.

Hi Sandro,
I cannot reproduce the issue. On line 4 in searchform.php is the closing PHP tag, nothing more, nothing less. Can you please reupload the theme and see, if the issue gets fixed?

Which PHP Version are you using?

I am on PHP 8.0.8 and line 4 on my side is:
$for = "search-input-{$this->id}";
Commenting this line the error goes away.
I’ll try later with a clean installation of Bricks 1.6.1

Edit:
Same error on two different setup with clean installation of WP 6.1.1 + Bricks 1.6.1
WP_DEBUG ENABLED
MacOS Mamp with php 7.4.21 and 8.0.8
Docker with php 7.4.29

I also see the issue in the error log… here is my original post:

Bricks Version: 1.6.1
Browser: Safari
OS: macOS
URL: Error Log File

When looking at the error log, I keep seeing this line

PHP Fatal error: Uncaught Error: Using $this when not in object context in /var/web/site/public_html/wp-content/themes/bricks/searchform.php:4

Here is the PHP Stacktrace

/var/web/site/public_html/wp-includes/general-template.php(308): require() /var/web/site/public_html/wp-content/themes/bricks/404.php(11): get_search_form(Array) /var/web/site/public_html/wp-includes/template-loader.php(106): include('/var/web/site/p...') /var/web/site/public_html/wp-blog-header.php(19): require_once('/var/web/site/p...') /var/web/site/public_html/index.php(17): require('/var/web/site/p...') {main} thrown in /var/web/site/public_html/wp-content/themes/bricks/searchform.php on line 4

The page seems to be working fine, but I discover this while looking for another issue.

I had the same problem and I solved it by updating the permalinks in wordpress (it didn’t show the product page in woocommerce)

Hope that helps!

1 Like

Updating the permalinks does not help for me :frowning:

try this sandro:

$for = “search-input-{static::id}”;

info:
["Using $this when not in object context." Here's the fix.]
Now the error was gone :slight_smile:

I also am getting the same fatal error after updating to 1.6.1. as those above -

PHP Fatal error: Uncaught Error: Using $this when not in object context in /public_html/wp-content/themes/bricks/searchform.php:4

This is incorrect, unfortunately, the previous version of the file was just the closing php tag but now as Sandro says line 4 is

$for = “search-input-{$this->id}”;

And I’m getting fatal errors due to it per my post above.

Could you possibly look into it again with the latest version?

This post should not be marked as SOLVED, there is definitely an issue. I had another website throwing the same error as described above

PHP Fatal error: Uncaught Error: Using $this when not in object context in ********/wp-content/themes/bricks/searchform.php:4

I commented out line 4 and the error disappeared but this is just a bandaid. something else should be causing the issue.

thank you in advance for looking into it.

1 Like

Hey guys,
I still cannot reproduce the issue, but added it to the bug tracker due to your reports.

Best regards,
timmse

1 Like

Hi all,
Same issue on 404 pages…
Maybe duplicate here: An error of type E_ERROR was caused in line 4 - #6 by yankiara

1 Like

I am having the same error after update to 1.6.1. Here’s my thread: Upgrade to 1.6.1 from 1.5.7 causes single template error - Bugs - Bricks Community Forum (bricksbuilder.io)

Hi all,

The dev team is aware of the issue.

The search form error is coming from Bricks 1.6.1, and will be fixed in the next update.

If you need a quick fix now you can change line 4 inside themes/bricks/searchform.php to:

$for = ‘search-input’;

Regards,
Jenn

2 Likes

i commented the line 4 with the error and i typed the code itchycode added but still not working
$for = ‘search-input’; and also try with double quotes and not working.

This is also not a solution. Pagination doesn’t work. This hid the error details lines. The error itself remains.

Can confirm on v1.6.1 , Im getting this php error on line 4 too.