PHP 8.1 - error on form page

Howdy,

I recently migrated a site, but having issues when I enable error logging (need it for other issue)
.

On the page with a gravity form I have this issue:

str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated (View: /var/www/site/wp-content/themes/test-theme/theme/partials/pagebuilder.blade.php) (View: /var/www/site/wp-content/themes/test-theme/theme/partials/pagebuilder.blade.php)

/var/www/site/wp-content/plugins/gravityforms/includes/fields/class-gf-field-list.php

                        if ( is_array( $choice ) ) {
                            $choice_value    = $choice['value'];
                            $choice_text     = $choice['text'];
                            $choice_selected = array_key_exists( 'isSelected', $choice ) ? $choice['isSelected'] : false;
                        } else {
                            $choice_value    = $choice;
                            $choice_text     = $choice;
                            $choice_selected = false;
                        }
                        $is_selected = empty( $value ) ? $choice_selected : $choice_value == $value;
                        $selected    = $is_selected ? "selected='selected'" : '';
                        $input .= "<option value='" . esc_attr( $choice_value ) . "' {$selected}>" . esc_html( $choice_text ) . '</option>';
                    }
                    $input .= '</select>';
     
                    break;
     
                default :
                    // a11y: inputs without a label must have the aria-label attribute set.
                    $input = "<input {$invalid_attribute} {$required_attribute} {$aria_describedby} aria-label='" . esc_attr( str_replace( '{0}', $row, $aria_label_template ) ) . "' data-aria-label-template='" . esc_attr( $aria_label_template ) . "' type='text' name='input_{$this->id}[]' value='" . esc_attr( $value ) . "' {$tabindex} {$disabled} />";
                    break;
            }

the section it’s highlighting is:

$input = "<input {$invalid_attribute} {$required_attribute} {$aria_describedby} aria-label='" . esc_attr( str_replace( '{0}', $row, $aria_label_template ) ) . "' data-aria-label-template='" . esc_attr( $aria_label_template ) . "' type='text' name='input_{$this->id}[]' value='" . esc_attr( $value ) . "' {$tabindex} {$disabled} />";

Any ideas how I can fix it?

I’m running Gravity Forms: 2.7.6

We’re aware of the issue. We’ll have it fixed in a future release. Thank you for the report.

2 Likes

Thanks!

There was another error:

/var/www/site/wp-content/plugins/gravityforms/includes/addon/class-gf-addon.php

$block_settings     = isset( $all_block_settings[ $form['id'] ][ $form['page_instance'] ] ) ? $all_block_settings[ $form['id'] ][ $form['page_instance'] ] : array();

With help of the oh mighty lord ChatGPT this helped:

$page_instance = isset($form['page_instance']) ? $form['page_instance'] : 0;
$block_settings = isset($all_block_settings[$form['id']][$page_instance]) ? $all_block_settings[$form['id']][$page_instance] : array();

^^^ dont know if this is correct fix, just had to push through to another error.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.