• Resolved Rogier Lankhorst

    (@rogierlankhorst)


    Hi there,

    We have an integration in Complianz which can add a GDPR checkbox automatically to a form if the users chooses so.

    To do this, we use:

    Forminator_API::add_form_field( $form_id, 'gdprcheckbox', $data );

    This worked fine for a couple of years, but recently we’ve found that this results in a fatal error on php 8.1.

    The reason seems to be that on line 695 of library/class-api.php, the existing array of this field type in the current form is selected. Then a count() is performed on this array.

    When the field does not exist yet, instead of returning 0, it returns a WP error. This results in a fatal error when the count is performed on the wp_error.

    Am I implementing the API wrong, or should the ‘get_form_fields_by_type’ function return an empty array if it doesn’t encounter a field of this type?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal error when using add_form_field api in php 8’ is closed to new replies.