Font Field Issue. Fatal error when we save form.

Hello,
I am developing module where I want to render Module 1 in Module 2 through form fields. I had also created one sample demo for it.

Module 1 : Basic Example
Module 2 : Test

Basic Example module uses font field. Following are steps, I followed to achieve my requirement.

Step 1 : I had registered form in Module 2.

Step 2 : Now rendered Module 1 CSS in Module 2’s “frontend.css.php” file.

Error : Now whenever I tried to save Form from Module 2, it shows error as given below

.fl-node-56fe20f143df1 .fl-example-text-font { color: #333333; <br /> <b>Fatal error</b>: Cannot use object of type stdClass as array in <b>C:\xampp\htdocs\git\wp-content\plugins\bb-sample-demo\basic-example\includes\frontend.css.php</b> on line <b>4</b><br/>

So tried one solution for it. Its worked perfect. Is this correct?

if ( is_object( $settings->font_family ) ) { $settings->font_family = json_decode(json_encode( $settings->font_family ), True); }

Well, Now when I open module again it gives error like this.

<br /><b>Fatal error</b>: Cannot use object of type stdClass as array in <b>C:\xampp\htdocs\git\wp-content\plugins\bb-plugin-ie-light-2\includes\field-font.php</b> on line <b>8</b><br />

I have also attached zip file of demo.Download here. Is I am doing anything wrong? Can you help me to resolve this issue?

Hi pc,

It looks like there are two issues here.

  1. Currently, font fields are required to have a default value. That is a bug and will be fixed at some point. For now you can add a default like so…
'font_family' => array(
    'type'          => 'font',
    'label'         => __('Font', 'fl-builder'),
    'default'       => array(
		'family'		=> 'Default',
		'weight'		=> 300
	),
),
  1. There is a typecasting issue going on in includes/field-font.php. If you add this to the top of that file, it should fix the issue…

<?php $value = ( array ) $value; // Make sure we have an array and not an object. ?>

I will get that in the next update.

Thanks,
Justin

Thank you, Justin…