Skip Navigation

[Resolved] Form now producing – Notice: Undefined index: post_reference_type error

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 8 replies, has 2 voices.

Last updated by Beda 5 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#1214839

I am trying to: return to a front end form that was working

Link to a page where the issue can be seen: hidden link

I expected to see: The form working

Instead, I got: The form with a new error message - Notice: Undefined index: post_reference_type in /home/mcf219design/public_html/wp-content/plugins/cred-frontend-editor/application/models/form/relationship.php on line 415

It was working when I last visited it in December 2018. I've updated all plugins.

#1214884

I have no permissions to see that form and will likely require to login

The error you get is likely related to a Post Reference Field that is present in the Toolset Form.
The same error is reported here: https://toolset.com/forums/topic/cannot-edit-or-create-forms-since-update-to-types-3-1-2/#post-1156134
Seems it was not addressed because you already have updated Toolset Versions installed.

But I cannot replicate the problem. Can you please either elaborate the precise steps to take or maybe send me a duplicate of the site?
https://toolset.com/faq/provide-supporters-copy-site/

#1214901

I see that no PRF (Post Reference Field) is used on that Form at all.
Previously I tried to trigger the error with a PRF included in the form and failed.
I tried now as you have it with 2 Relationships, still, I cannot see that error.

I've tried a new form on a new page and can see the same issue
(hidden link, hidden link)

Can you create a copy of this site and send it to me?
I'll need to strip it apart and see where the problem is generated, it must be replicable somehow.
https://toolset.com/faq/provide-supporters-copy-site/

#1216964

Thus duplicate produces a row of Apache and PHP errors. I was able to deploy it only with several manual adjustments.
This is strange, usually, the Duplicators work fine if they also completed properly on the origin site.
The errors seem mainly related to missing database tables, but also several PHP 7.x compatibility issues right upon the site start (Toolset Types fixed those here: https://toolset.com/errata/php-7-3-shows-warnings-about-continue-statement-in-types/)

I see those PHP errors affect mainly these plugins:
revslider, duplicator (wow, who would have thought this)

In any case, I was able to deploy the site finally and on the homepage, I found another (additional to above) error:

Warning: preg_match(): Compilation failed: invalid range in character class at offset 12 in /js_composer_theme/include/classes/shortcodes/vc-basic-grid.php on line 184

Removing all plugins (deactivating) unless Toolset resolved all issues unless the one on add-event/ page you reported here.
I also removed the "must use" plugin, cleaned the .htaccess and wp-config.php, which did not solve this problem either.

Even disabling the theme did not solve this issue.

The code affected here, cred-frontend-editor/application/models/form/relationship.php line 415, says:

$field[ 'data' ][ 'post_type' ] = $field[ 'data' ][ 'post_reference_type' ];

Hence, it fails on $field[ 'data' ][ 'post_reference_type' ]; assuming [ 'post_reference_type' ] to be an unexisting index of $field['data'] and that code is explicitely used for post reference fields. But there are no such fields in that form.
Only relationships, no post references.

The data index has an array of values:

["data"]=> array(10) { 
		["slug-pre-save"]=> string(11) "event-venue" 
		["placeholder"]=> string(0) "" 
		["user_default_value"]=> string(0) "" 
		["repetitive"]=> string(1) "0" 
		["custom_use"]=> string(0) "" 
		["conditional_display"]=> array(0) { } 
		["submit-key"]=> string(11) "event-venue" 
		["disabled_by_type"]=> int(0) 
		["validate"]=> array(0) { 

		} 
		["post_type"]=> NULL 
	} 

[ 'post_reference_type' ] is not there.
The data on your site tells me that this should be the field "event-venue", that is not a PRF but a simple single line, and that is the reason, there is no [ 'post_reference_type' ]

And I believe I found what is the reason for the form assuming it is a PRF field...
You also have a Relationship with the exact same slug!
In fact, as soon you rename the Custom Field event-venue to event-venue-anything-new the issue is resolved.

Now, I am quite sure this is replicable, and probably expected as you should rarely use the same slug for 2 things on a site, but then, it's surely not OK for Toolset forms to assume a PRF just because you happen to have a field with the same slug as a relationship on your site.

I am escalating this and will try a clean reproduction tomorrow, and a fix if needed.

Meanwhile, you could rename that field - but be aware that renaming it, also will, of course, change the way you have to display already saved data, so maybe you better wait until I have a proper solution or precise statement from the DEV about this.

#1217313

Hi Beda,

Many thanks for your continued support. Glad you managed to get the duplicate site up and running. Not sure why the tables got dropped.

Ahhh, that would make sense. I didn't realise that we had duplicate slugs. I won't try renaming the field yet until I hear back from you, in case there's any further underlying issue but, hopefully thats the only problem and can be easily fixed.

Kind regards
James

#1217447

Yes, I'll let you know here as soon I have some news about this.

#1219432

We now have an erratum for this problem, although without a solution yet:
https://toolset.com/errata/the-custom-field-behaves-like-a-relationship-field-if-its-slug-is-the-same-as-a-post-relationships-slug/

Note, it does not mention the PHP notice, because that is just a side-effect of the core issue which is, fields with the same slug as relationships are interpreted as relationships field (and even rendered as Select2)

You can follow the issue there, where also eventual patches will be shared and the erratum will be closed as fixed once it's resolved in the core.

I'll update you here as well once there is a solution released.

#1222247

Many thanks Beda, that's great. I've amended the event-venue slug which has indeed removed the error on the page, and I'll keep an eye out for any updates on the erratum.

Many thanks for your help with this.

Best regards
James

#1222255

OK, thanks for the heads up.
Internally, there is no progress yet.
We will keep updating this erratum:
https://toolset.com/errata/the-custom-field-behaves-like-a-relationship-field-if-its-slug-is-the-same-as-a-post-relationships-slug/