wpsight / wpcasa

WPCasa WordPress Real Estate
https://wpcasa.com
GNU General Public License v2.0
42 stars 23 forks source link

Report after testing Ninja Forms with PHP 8.2 #127

Open Jimmi08 opened 3 months ago

Jimmi08 commented 3 months ago

Prerequisites

Description

Addon Ninja Forms should be updated, but the repo is not, so I am writing this here. I have got 2 issues with latest version.

  1. not able to select the agent email field in admin area

Original code:

if( '_hidden' == $field->get_type() )
$form_fields[ $form_field_id ] = $field['data']['label'];

this didn't work, I had to change it to:

if( 'hidden' == $field->get_setting('type') )
$form_fields[ $form_field_id ] = $field->get_setting('label');
  1. fatal error on frontend (or warning, I am not sure now) $ninja_forms_loading was NULL Original code:
global $ninja_forms_loading; 
if( $_form_id && $_field_id && $_form_id == $form_id )
$ninja_forms_loading->update_field_value( $_field_id, antispambot( get_the_author_meta( 'email' ) ) );

Working code (not sure if it is the right fix)

$ninja_forms_loading = Ninja_Forms()->form($form_id);
if( $_form_id && $_field_id && $_form_id == $form_id ) {
    $field = $ninja_forms_loading->get_field($_field_id);
    $field->update_setting('default', antispambot(get_the_author_meta('email')));
}

Used position: After the end

Thanks

Jimmi08 commented 3 months ago

I don't know if this is ninja forms related or wpcasa: UpTown theme is used.

image

codestylist commented 3 months ago

Thank you @Jimmi08 for your message. We have not noticed this issue yet and will investigate it further.

Jimmi08 commented 3 months ago

@codestylist Hi Sandro, I did fresh installation to be sure: - PHP 8.1

Go to settings - no email field image

Frontend: image

Jimmi08 commented 3 months ago

I don't know if this is ninja forms related or wpcasa: UpTown theme is used.

image

This is ninja form issue, it is reported on official repository many times, it can be fixed in theme with filter. I posted solution there. Just to have it complete for the future:

function decode_ninja_forms_display_form_settings($settings, $form_id)
{
    $settings['fieldsMarkedRequired'] = html_entity_decode($settings['fieldsMarkedRequired']);

    return $settings;
}
add_filter('ninja_forms_display_form_settings', 'decode_ninja_forms_display_form_settings', 10, 2);