Troubleshooting Empty Form Titles and PHP 8.0 Deprecation Warnings in Fluent Forms
Content
Users of the Fluent Forms plugin have recently encountered two distinct technical issues following updates: one involving empty form titles when using custom code, and another related to PHP 8.0 compatibility. This guide explains the causes and provides solutions for both problems.
Issue 1: Empty Form Title When Retrieving Forms by ID
The Problem: After updating to Fluent Forms version 6.0.4, custom PHP code that was previously working to retrieve a form's title suddenly returns an empty value. The code in question typically looks like this:
$formApi = fluentFormApi('forms');
$form = $formApi->form($id);
$title = $form->title; // This now returns empty
Why It Happens: This issue is linked to a change in the internal FormProperties class. The class's __get() method now uses property_exists() to check for a property before returning it. However, the internal form object is a Model that uses its own __get() method to dynamically retrieve properties from the database. Since the title property isn't set as a class property but is accessed dynamically, property_exists() returns false, resulting in an empty value.
Solution: The most direct solution is to use the form object's get() method, which is designed to bypass this internal property check and reliably fetch the value.
Modify your code as follows:
$formApi = fluentFormApi('forms');
$form = $formApi->form($id);
$title = $form->get('title'); // Use the get() method
This approach is the recommended and future-proof way to access form properties and should be compatible with both older and newer versions of Fluent Forms.
For developers who only have a form ID and need to quickly get the title or full object without using the API, a direct database query is an alternative. The Fluent Forms team has suggested the following method using their query builder:
$formObject = wpFluent()->table('fluentform_forms')->find($formId);
$title = $formObject->title;
Issue 2: PHP 8.0 Deprecation Warning
The Problem: When activating or using Fluent Forms on a server running PHP 8.0, a deprecation notice may appear:
Deprecated: Method ReflectionParameter::getClass() is deprecated in /.../wp-content/plugins/fluentform/framework/Foundation/Container.php on line 210
Why It Happens: The ReflectionParameter::getClass() method was deprecated in PHP 8.0. The plugin's code at the specified location was using this outdated method, triggering the warning. Deprecation notices are not fatal errors and the plugin should continue to function, but they indicate code that needs updating for future PHP versions.
Solution: As a user, you cannot directly fix this code. This type of warning requires an update from the Fluent Forms development team to replace the deprecated function with a PHP 8.0-compatible alternative.
The recommended actions are:
- Ensure your plugin is updated: Always run the latest version of Fluent Forms. The team likely addressed this in a subsequent update. Check your WordPress updates page to ensure you have installed all available patches.
- Temporarily suppress deprecation notices: If the warning is causing clutter in your debug logs but the plugin is working, you can adjust your site's
wp-config.phpfile to not display deprecation notices. It is not recommended to hide all errors, but you can target deprecation notices specifically if needed for a short period. - Check the official plugin page: For confirmed bugs like this, the Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder team often publishes information about fixed issues in their official changelog. Reviewing this can confirm if a update has been released to resolve the problem.
By applying these solutions, you can resolve the issue of empty titles in your custom code and manage the PHP 8.0 deprecation warning while waiting for an official plugin update.
Related Support Threads Support
-
Possible error on __get implementation of FormPropertieshttps://wordpress.org/support/topic/possible-rror-on-__get-implementation-of-formproperties/
-
Deprecated: Method ReflectionParameter in PHP 8.0https://wordpress.org/support/topic/deprecated-method-reflectionparameter-in-php-8-0/
-
Get Form Object by IDhttps://wordpress.org/support/topic/get-form-object-by-id/