Error when creating GF via GFAPI::add_form [RESOLVED]

Hello, I am currently getting the following error when trying to create a GF form via GFAPI::add_form. Any idea what’s going on and how to fix this? BTW, I retrieved the array data from a form from one site (via GFAPI::get_form) whose GF plugin instance is the same version (latest - 2.7.3) as the GF plugin on another site where I am using GFAPI::add_form.

Fatal error : Uncaught Error: Call to undefined method GF_Field_HTML::__set_state() in …/wp-content/plugins/my-plugin/plugin.php:146 Stack trace: #0 …/wp-admin/includes/plugin.php(2314): include_once() #1 …/wp-admin/plugins.php(192): plugin_sandbox_scrape(‘my-plugin-…’) #2 {main} thrown in …/wp-content/plugins/my-plugin/plugin.php on line 146

Can you share the code from your custom plugin? If you’d prefer not to share the code publicly, you could open a support ticket.

Relevant code which produces the error:

$result = GFAPI::add_form(array ( ‘title’ => ‘HELLO WORLD’, ‘description’ => ‘’, ‘labelPlacement’ => ‘top_label’, ‘descriptionPlacement’ => ‘below’, ‘button’ => array ( ‘type’ => ‘text’, ‘text’ => ‘BOOK NOW’, ‘imageUrl’ => ‘’, ‘conditionalLogic’ => ‘’, ‘width’ => ‘auto’, ‘location’ => ‘bottom’, ‘layoutGridColumnSpan’ => 12, ‘id’ => ‘submit’, ), ‘fields’ => array ( 0 => GF_Field_HTML::__set_state(array( ‘type’ => ‘html’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 4, ‘formId’ => 1, ‘label’ => ‘’, ‘adminLabel’ => ‘’, ‘isRequired’ => false, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘displayOnly’ => true, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘’, ‘cssClass’ => ‘’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘content’ => ’
BOOK YOUR SEAT
', ‘disableMargins’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 6, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘59994fc7’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘pageNumber’ => 1, ‘fields’ => ‘’, )), 1 => GF_Field_Radio::__set_state(array( ‘type’ => ‘radio’, ‘_supports_state_validation’ => true, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘id’ => 20, ‘formId’ => 1, ‘label’ => ‘FLIGHT TYPE’, ‘adminLabel’ => ‘’, ‘isRequired’ => true, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘validateState’ => true, ‘inputs’ => NULL, ‘choices’ => array ( 0 => array ( ‘text’ => ‘ONE-WAY’, ‘value’ => ‘one-way’, ‘isSelected’ => true, ‘price’ => ‘’, ), ), ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘’, ‘cssClass’ => ‘flight-type’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘conditionalLogic’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 3, ‘enableOtherChoice’ => ‘’, ‘enablePrice’ => ‘’, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘59994fc7’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘checkboxLabel’ => ‘’, ‘enableChoiceValue’ => true, ‘errors’ => array ( ), ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, ‘layoutSpacerGridColumnSpan’ => 3, )), 2 => GF_Field_Select::__set_state(array( ‘type’ => ‘select’, ‘_supports_state_validation’ => true, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘id’ => 8, ‘formId’ => 1, ‘label’ => ‘From’, ‘adminLabel’ => ‘’, ‘isRequired’ => true, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘choices’ => array ( 0 => array ( ‘text’ => ‘New York (BLM)’, ‘value’ => ‘BLM494’, ‘isSelected’ => false, ‘price’ => ‘’, ), 1 => array ( ‘text’ => ‘Fort Lauderdale (FLL)’, ‘value’ => ‘FLL494’, ‘isSelected’ => false, ‘price’ => ‘’, ), ), ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘FROM’, ‘cssClass’ => ‘location’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘conditionalLogic’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 3, ‘enablePrice’ => ‘’, ‘enableEnhancedUI’ => 1, ‘layoutGroupId’ => ‘9c5f2e9a’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘errors’ => array ( ), ‘checkboxLabel’ => ‘’, ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, ‘enableChoiceValue’ => true, )), 3 => GF_Field_Select::__set_state(array( ‘type’ => ‘select’, ‘_supports_state_validation’ => true, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘id’ => 9, ‘formId’ => 1, ‘label’ => ‘To’, ‘adminLabel’ => ‘’, ‘isRequired’ => true, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘choices’ => array ( 0 => array ( ‘text’ => ‘New York (BLM)’, ‘value’ => ‘BLM494’, ‘isSelected’ => false, ‘price’ => ‘’, ), 1 => array ( ‘text’ => ‘Fort Lauderdale (FLL)’, ‘value’ => ‘FLL494’, ‘isSelected’ => false, ‘price’ => ‘’, ), ), ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘TO’, ‘cssClass’ => ‘location’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘conditionalLogic’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 3, ‘enablePrice’ => ‘’, ‘enableEnhancedUI’ => 1, ‘layoutGroupId’ => ‘9c5f2e9a’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘errors’ => array ( ), ‘checkboxLabel’ => ‘’, ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, ‘enableChoiceValue’ => true, )), 4 => GF_Field_Date::__set_state(array( ‘type’ => ‘date’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 7, ‘formId’ => 1, ‘label’ => ‘Depart’, ‘adminLabel’ => ‘’, ‘isRequired’ => true, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘dateType’ => ‘datepicker’, ‘dateFormat’ => ‘mdy’, ‘dateFormatPlacement’ => ‘below’, ‘calendarIconType’ => ‘none’, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘DEPART’, ‘cssClass’ => ‘date depart-date’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘calendarIconUrl’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 3, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘9c5f2e9a’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘checkboxLabel’ => ‘’, ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, ‘errors’ => array ( ), )), 5 => GF_Field_Number::__set_state(array( ‘type’ => ‘number’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 12, ‘formId’ => 1, ‘label’ => ‘Passengers’, ‘adminLabel’ => ‘’, ‘isRequired’ => true, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘numberFormat’ => ‘decimal_dot’, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘# PASSENGERS’, ‘cssClass’ => ‘passengers’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘enableCalculation’ => false, ‘rangeMin’ => ‘1’, ‘rangeMax’ => ‘999’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 3, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘9c5f2e9a’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘errors’ => array ( ), ‘checkboxLabel’ => ‘’, ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, )), 6 => GF_Field_Date::__set_state(array( ‘type’ => ‘date’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 6, ‘formId’ => 1, ‘label’ => ‘Return’, ‘adminLabel’ => ‘’, ‘isRequired’ => false, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘hidden’, ‘inputs’ => NULL, ‘dateType’ => ‘datepicker’, ‘dateFormat’ => ‘mdy’, ‘dateFormatPlacement’ => ‘below’, ‘calendarIconType’ => ‘none’, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘hidden_label’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘RETURN’, ‘cssClass’ => ‘date return-date’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘calendarIconUrl’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 12, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘a63bb1a1’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘checkboxLabel’ => ‘’, ‘pageNumber’ => 1, ‘fields’ => ‘’, ‘displayOnly’ => ‘’, ‘errors’ => array ( ), )), 7 => GF_Field_HTML::__set_state(array( ‘type’ => ‘html’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 22, ‘formId’ => 1, ‘label’ => ‘HTML Block’, ‘adminLabel’ => ‘’, ‘isRequired’ => false, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘displayOnly’ => true, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘’, ‘cssClass’ => ‘airline-msg’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘content’ => ‘Flights conducted by Northeastern Aviation Corp. holder of Air Carrier Certificate number AOYA206C acting as Direct Air Carrier’, ‘disableMargins’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 12, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘99125b4c’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘pageNumber’ => 1, ‘fields’ => ‘’, )), 8 => GF_Field_HTML::__set_state(array( ‘type’ => ‘html’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 23, ‘formId’ => 1, ‘label’ => ‘HTML Block’, ‘adminLabel’ => ‘’, ‘isRequired’ => false, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘displayOnly’ => true, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘’, ‘cssClass’ => ‘participant-agreement-msg’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘content’ => ‘Review and sign our participant agreement’, ‘disableMargins’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 12, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘2fd460d6’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘pageNumber’ => 1, ‘fields’ => ‘’, )), 9 => GF_Field_HTML::__set_state(array( ‘type’ => ‘html’, ‘_is_entry_detail’ => NULL, ‘_context_properties’ => array ( ), ‘_merge_tag_modifiers’ => array ( ), ‘_supports_state_validation’ => false, ‘id’ => 21, ‘formId’ => 1, ‘label’ => ‘HTML Block’, ‘adminLabel’ => ‘’, ‘isRequired’ => false, ‘size’ => ‘large’, ‘errorMessage’ => ‘’, ‘visibility’ => ‘visible’, ‘inputs’ => NULL, ‘displayOnly’ => true, ‘description’ => ‘’, ‘allowsPrepopulate’ => false, ‘inputMask’ => false, ‘inputMaskValue’ => ‘’, ‘inputMaskIsCustom’ => false, ‘maxLength’ => ‘’, ‘inputType’ => ‘’, ‘labelPlacement’ => ‘’, ‘descriptionPlacement’ => ‘’, ‘subLabelPlacement’ => ‘’, ‘placeholder’ => ‘’, ‘cssClass’ => ‘round-trip-unavailable-msg’, ‘inputName’ => ‘’, ‘noDuplicates’ => false, ‘defaultValue’ => ‘’, ‘enableAutocomplete’ => false, ‘autocompleteAttribute’ => ‘’, ‘choices’ => ‘’, ‘conditionalLogic’ => ‘’, ‘content’ => ‘For round trips, please contact our customer service.’, ‘disableMargins’ => ‘’, ‘productField’ => ‘’, ‘layoutGridColumnSpan’ => 12, ‘enableEnhancedUI’ => 0, ‘layoutGroupId’ => ‘ccd2a93c’, ‘multipleFiles’ => false, ‘maxFiles’ => ‘’, ‘calculationFormula’ => ‘’, ‘calculationRounding’ => ‘’, ‘enableCalculation’ => ‘’, ‘disableQuantity’ => false, ‘displayAllCategories’ => false, ‘useRichTextEditor’ => false, ‘pageNumber’ => 1, ‘fields’ => ‘’, )), ), ‘version’ => ‘2.6.8’, ‘id’ => 1, ‘markupVersion’ => 2, ‘nextFieldId’ => 24, ‘useCurrentUserAsAuthor’ => true, ‘postContentTemplateEnabled’ => false, ‘postTitleTemplateEnabled’ => false, ‘postTitleTemplate’ => ‘’, ‘postContentTemplate’ => ‘’, ‘lastPageButton’ => NULL, ‘pagination’ => NULL, ‘firstPageCssClass’ => NULL, ‘subLabelPlacement’ => ‘below’, ‘requiredIndicator’ => ‘custom’, ‘customRequiredIndicator’ => ‘’, ‘cssClass’ => ‘’, ‘buttonType’ => ‘text’, ‘buttonText’ => ‘REQUEST’, ‘buttonImageURL’ => ‘’, ‘form_button_conditional_logic_object’ => ‘’, ‘form_button_conditional_logic’ => ‘0’, ‘saveButtonText’ => ‘Save and Continue Later’, ‘limitEntries’ => false, ‘limitEntriesCount’ => ‘’, ‘limitEntriesPeriod’ => ‘’, ‘limitEntriesMessage’ => ‘’, ‘scheduleForm’ => false, ‘scheduleStart’ => ‘’, ‘scheduleEnd’ => ‘’, ‘schedulePendingMessage’ => ‘’, ‘scheduleMessage’ => ‘’, ‘requireLogin’ => false, ‘requireLoginMessage’ => ‘’, ‘enableAnimation’ => true, ‘validationSummary’ => false, ‘saveEnabled’ => ‘’, ‘enableHoneypot’ => true, ‘save’ => array ( ‘enabled’ => false, ‘button’ => array ( ‘type’ => ‘link’, ‘text’ => ‘Save and Continue Later’, ), ), ‘scheduleStartHour’ => ‘’, ‘scheduleStartMinute’ => ‘’, ‘scheduleStartAmpm’ => ‘’, ‘scheduleEndHour’ => ‘’, ‘scheduleEndMinute’ => ‘’, ‘scheduleEndAmpm’ => ‘’, ‘deprecated’ => ‘’, ‘notifications’ => array ( ‘612e6d2999a16’ => array ( ‘id’ => ‘612e6d2999a16’, ‘isActive’ => true, ‘to’ => ‘{admin_email}’, ‘name’ => ‘Admin Notification’, ‘event’ => ‘form_submission’, ‘toType’ => ‘email’, ‘subject’ => ‘New Booking Request (from Desktop)’, ‘message’ => ‘{all_fields}’, ‘service’ => ‘wordpress’, ‘toEmail’ => ‘{admin_email}’, ‘toField’ => ‘’, ‘routing’ => array ( 0 => array ( ), ), ‘fromName’ => ‘’, ‘from’ => ‘{admin_email}’, ‘replyTo’ => ‘’, ‘bcc’ => ‘’, ‘disableAutoformat’ => false, ‘notification_conditional_logic_object’ => ‘’, ‘notification_conditional_logic’ => ‘0’, ‘conditionalLogic’ => NULL, ‘cc’ => ‘’, ‘enableAttachments’ => false, ), ), ‘confirmations’ => array ( ‘612e6d2999fed’ => array ( ‘id’ => ‘612e6d2999fed’, ‘name’ => ‘Default Confirmation’, ‘isDefault’ => true, ‘type’ => ‘redirect’, ‘message’ => ‘Thanks for contacting us! We will get in touch with you shortly.’, ‘url’ => ‘https://www.example.com’, ‘pageId’ => ‘’, ‘queryString’ => ‘’, ‘event’ => ‘’, ‘disableAutoformat’ => false, ‘page’ => ‘’, ‘conditionalLogic’ => array ( ), ), ), ‘is_active’ => ‘1’, ‘date_created’ => ‘2021-08-31 17:55:53’, ‘is_trash’ => ‘0’));

The problem is all the CLASS_NAME::__set_state() calls; that is not a method of the Gravity Forms GF_Field classes and is not the correct way to add fields to a form you are creating.

The simplest way to define a field when creating a new form is by passing an array containing its properties, e.g.,

'fields' => array( array( 'type' => 'html', 'id' => 4 ) )

Gravity Forms will handle creating the field objects based on those properties just before it adds the form to the database.

I see, so I suppose it is not always possible to plug into the function GFAPI::add_form() everything that GFAPI::get_form() spits out, is that correct? So, I suppose the following will not always work!

$form_meta = GFAPI::get_form(1); // website a
GFAPI::add_form($form_meta); // website b

If this will not always work, then I suppose we need to tweak certain syntax and values within $form_meta before feeding it to add_form() like you suggest.

How are you transferring the meta from site a to site b?

Thanks, I took your advice and I realized the problem was I had exported the meta from site a using something like print_r(), the solution was to use var_export(), which feeds data to add_form() much better!