Skip Navigation

[Resolved] One of the hidden form fields is not inserting

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2639377
toolset002.jpg
toolset003.jpg
toolset004.jpg
toolset005.jpg
toolset001.jpg

I have a form with hidden fields to insert values into the custom fields. It works for the first field pick-course but not for the second pick-type. I've tried capitalizing and all lower case but it won't stick. See screenshots.

There is a condition on pick-course which is the Pick Type = course, but I don't see how that matters since that's actually the one that does insert.

Pick-type is a select field and pick-course is an object reference.

Screenshot 1 shows my form. 2 is what the insertion looks like, as you can see it did not take pick type. 3 is when I manually select the pick type and then you can see that the pick-course did insert. 4 and 5 are the custom fields.

What am I missing?

#2639659

Nigel
Supporter

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

Timezone: Europe/London (GMT+00:00)

Sorry, but I'm really struggling to understand what the issue is here, perhaps you could elaborate further.

I see in screenshot 1 a form which contains nothing more than two hidden generic fields and a submit button.

These are generic fields and so when the form is submitted they are discarded. Which means you presumably are running some code on the server—I would imagine with the cred_save_data hook—to do something based on the submitted field values, otherwise the form does nothing.

Is the problem with the values of these fields when the form is submitted? You are expecting one thing, but getting something else?

Where is the form displayed?

It looks like the pick-course field should have the value of a URL parameter id coming from the url of the page where the form is displayed.

While the second field, pick-type, would always be the default "Course", because there is nothing to set it to be any different.

Could you please expand on what it is you are trying to do with this form and what you expect to happen?

#2640367

Yes, the course id comes from the URL and it works, it shows the right course selected, in other words, the hidden fields is passed and inserted into the DB.

The pick-course is of field type Course. If I pass another course id, it updates, hence, the hidden field is passed and it works. The same should work for the second field but it does not.

As for what I'm trying to do is pass data on via a hidden field that the user does not need to see and insert it in the Pick Object which works for one of the hidden fields. What do I expect to happen, I expect both hidden fields to be inserted.

#2640533

Hi,

Thank you for sharing these details.

Based on what you've shared the second field should also be working. To troubleshoot this, I'll need to see how these fields and the form are set up in the admin area.

Can you please share temporary admin login details and the exact steps to see the issue?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2641297

Thank you for sharing the access details.

On my test website, I was able to make a select type field work, by changing its generic field code to:


[cred_generic_field type='hidden' field='wpcf-pick-type']
	{
		"default":"course",
		"persist":"1"
	}
[/cred_generic_field]

Explanation:

1. The default value should be 'course' and not 'Course' because, in the field's setting, we're storing the value as 'course'.

2. The "persist":"1" tells the system that we'd like to save this generic field value to the database. By default, generic field values are not saved in the database and they are used for processing through the custom code, on the form submission.

3. The generic field's slug should be complete with the prefix 'wpcf-' ( i.e. wpcf-pick-type ), because that is how the Tookset Type's defined/registered custom field value is stored in the database.

Note: I can understand that you must be wondering why it is working for the 'post reference' type field, without these steps. The post-reference field's data is technically not stored as a custom field value. It is stored in a post-relationship structure, which would explain its exceptional treatment.

#2641701

That's brilliant, that did the trick. Thank you