Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with GravityForms styling when the GravityForms MultiLingual plugin is active, specifically related to the

gform_pre_render

function altering the form wrapper, here's a step-by-step solution.
Solution:
1. Navigate to the file at

/wp-content/plugins/gravityforms-multilingual/inc/gravity-forms-multilingual.class.php

.
2. Locate the code around line 983:

public function gform_pre_render( $form ) {<br />return $this->translate( $form );<br />}

3. Replace the existing code with the following to preserve specific form data:

public function gform_pre_render( $form ) {<br />// Preserve the page_instance key if it exists<br />$page_instance = isset( $form['page_instance'] ) ? $form['page_instance'] : null;<br /><br />// Translate the form<br />$form =  $this->translate( $form );<br /><br />// Reassign the page_instance key after translation<br />if ( $page_instance !== null ) {<br />$form['page_instance'] = $page_instance;<br />}<br /><br />return $form;<br />}

Please check if this modification resolves the issue on your site.

Keep in mind that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 7 replies, has 1 voice.

Last updated by antoniusH 1 week, 2 days ago.

Assisted by: Osama Mersal.

Author Posts
December 28, 2024 at 9:53 am #16549805

antoniusH

Background of the issue:
I am trying to fix an issue with the GravityForms styling when the GravityForms MultiLingual plugin is active. In the file gravityforms-multilingual/inc/gravity-forms-multilingual.class.php, there is a filter being added: add_filter( 'gform_pre_render', [ $this, 'gform_pre_render' ] );. The gform_pre_render makes a single call to return $this->translate( $form );. However, something in that function breaks the wrapper of the GravityForm. It removes the data-form-index="0" attribute somehow, causing the inline CSS to be disregarded. Commenting out that filter brings back the data-index attribute, and thus fixes the styling. Link to a page where the issue can be seen: hidden link

Symptoms:
The GravityForms lose styling when the GravityForms MultiLingual plugin is active. The data-form-index="0" attribute is removed, causing the inline CSS to be disregarded.

Questions:
Why does the gform_pre_render function remove the data-form-index attribute?
How can I fix the styling issue without commenting out the filter?

December 28, 2024 at 11:58 am #16549943

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Could you please try to recreate this issue on the following sandbox, so that we can confirm if we are handling a general bug:

One-Click-Login:
hidden link

Please leave us a comment on this ticket once you are done with this task.

Best regards
Andreas

December 29, 2024 at 10:14 am #16550919

antoniusH

Thanks for the reply! I recreated the issue in the sandbox. If you visit the sample page at hidden link, the form wrapper is also missing the data-form-index="0" attribute and thus my styling is lost. If I deactivate the GravityFroms Multilingual plugin, the attribute (and the styling) is back -- in this case, styling refers simply to the background color of the submit button.

December 30, 2024 at 10:01 am #16552723

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I'm Osama from WPML forums support. I'll be glad to help you today.

Thanks for replicating the issue. Please let me know how the button background is added.

Best regards,
Osama

December 30, 2024 at 10:06 am #16552732

antoniusH

Hi Osama!

It's a block setting on the form when editing the page: hidden link

You can find it under the panel `Button Styles`. The color property label is `Background` over there.

December 30, 2024 at 10:50 am #16552936

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your reply. I'll consult our compatibility team and update you as soon as they reply.

Best regards,
Osama

January 7, 2025 at 10:41 am #16568986

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your patience. Please check the following steps:

1- Edit the (/wp-content/plugins/gravityforms-multilingual/inc/gravity-forms-multilingual.class.php) file
2- Look for line 983

*public function gform_pre_render( $form ) {
	return $this->translate( $form );
	}

3- Replace the above code with the following

	public function gform_pre_render( $form ) {
		// Preserve the page_instance key if it exists
		$page_instance = isset( $form['page_instance'] ) ? $form['page_instance'] : null;

		// Translate the form
		$form =  $this->translate( $form );

		// Reassign the page_instance key after translation
		if ( $page_instance !== null ) {
			$form['page_instance'] = $page_instance;
		}

		return $form;
	}

I applied the above steps on the sandbox site. Please check if it works correctly.

Best regards,
Osama

January 9, 2025 at 11:01 am #16577191

antoniusH

That has worked, thank you very much!