[Waiting for user confirmation] Form filtering Post Type in View is displaying but not saving the input data

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Related documentation: CRED Forms for Child Content

This topic contains 6 replies, has 2 voices, and was last updated by  Luo Yang 6 days, 10 hours ago. The support staff assigned to this topic is Luo Yang.

Viewing 7 posts - 1 through 7 (of 7 total)
Author
Posts
#569678

I am trying to: Hello we are filtering a post type in a view before using a sort code to display the data in a dropdown/select input element, the data is displaying fine, but when the form is submitted the input element recorded but other standard form data is. I have double checked the postmeta for the submitted form to confirm this.

Thank you

Link to a page where the issue can be seen:

View: https://old.sshcorporate.co.uk/wp-admin/admin.php?page=views-editor&view_id=901

Form: https://old.sshcorporate.co.uk/wp-admin/post.php?post=24&action=edit

Post Type for the Filtered data (Drivers): https://old.sshcorporate.co.uk/wp-admin/admin.php?page=wpcf-edit-type&wpcf-post-type=driver

I expected to see:

The form shows the filtered data under the label "New List:" and the same data using the standard method of showing data in a form (but clearly not filtered) under the label (Old List).

Instead, I got:

So "New List" data is not being saved or sent through via email which we want it to do.

#569722

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

Supporter Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Peter,

Thanks for the details, I can login your website.
But I am not sure where and how I can see the problem you mentioned:
So "New List" data is not being saved or sent through via email which we want it to do.

Could you describe detail steps to produce above problem?

Thanks

#569826

Sorry if it was not clear - have tried to explain the issue -

The Driver post type is a parent of the Booking post type.

Originally we had a Select field on the CRED Add Booking Form (ID:24) that just bought through every Driver Name so a Booking could be assigned to the correct driver. This was achieved with the following Shortcode -

[cred_field field='_wpcf_belongs_driver_id' value='' required="true" class='form-control' output='bootstrap']

This is still on the CRED form labelled as Old List.

We need to filter the list of Driver Names based on whether they are Approved in the new Driver Select field called 'driver-allowed' - so we want the Select to only show Drivers who are marked in the field as Assigned(1) and not display Drivers marked as Suspended(2) or Left(3). We have created a View that filters the Driver Posts called 'Driver Allowed'

The issue is we have put the output of the View into a generic Select field on the Add Booking form so the correct list is displayed (labelled as New List), but the Booking is not writing the chosen value with the Booking Post as a child of the chosen Driver post.

The generic field on the form shows the filtered drivers in the Select dropdown, but does not appear to write the value to the database and the Booking is not registering as a child record of the parent Driver.

<select field='driver-allowed' name="driver-allowed" id="cred_form_24_1-select-1-1505305099" class="form-control wpt-form-select form-select select select js-wpt-validate" output="bootstrap" select_text="HINT: Type first letter of Drivers Christian Name for speed" data-wpt-field-title="driver Parent" data-wpt-type="select" name="select-_wpcf_belongs_driver_id">

  [wpv-view name="driver-allowed" orderby="title" order="asc" cached="off"]

</select>

How can we get the chosen name to correctly save so the Booking is a child of the correct Driver?

#569865

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

Supporter Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I am checking it in your website, will update this thread if there is anything found, but I am on a trip, may answer it later.

#570096

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

Supporter Timezone: Asia/Hong_Kong (GMT+08:00)

In your case, it needs some PHP codes, for example you can try with CRED action hook "cred_save_data",

When user submit the CRED form, use action hook "cred_save_data", trigger a custom PHP function
https://wp-types.com/documentation/programmer-reference/cred-api/#cred_save_data
This hook allows doing a custom action when post data is saved to database.

In this PHP function, get the value of your "generic Select field", and save it into database:
https://codex.wordpress.org/Function_Reference/update_post_meta

#570303

Hello, thank you for that I have been able to use the 'cred_save_data' to save this data to the database.

However even though this data is now saved as postmeta along with the rest of the post data to "post_type": booking all data except for this postmeta can be show shown using

[types field='order-number'][/types]

on the website by using a using a template "Toolset > Content Templates > Bookings Display" however

[types field='driver-allowed'][/types]

does not return any data?

https://old.sshcorporate.co.uk/wp-admin/admin.php?page=ct-editor&ct_id=88&action=edit

and

https://old.sshcorporate.co.uk/wp-admin/edit.php?post_type=booking

So is there a way of making a "Content Template" pull postmeta directly for the post it is displaying ?

There is also a second issue of the information not being able to appear in the email sent on form submit, though solving this is less important.

#570314

Luo Yang
Forum moderator

Supporter languages: English (English ) Chinese (Simplified) (简体中文 )

Supporter Timezone: Asia/Hong_Kong (GMT+08:00)

It is a new question.

Since you did not point out the problem page URL, where and how can I see the problem:
[types field='driver-allowed'][/types] does not return any data.

So I have to guess what happened in your website, I assume we are talking about this case:
in the single "booking" post, for example:
https://old.sshcorporate.co.uk/booking/xxx-xxx-9999-4/

there should be some result just after text:
"Data Should display here:"

If it is, please edit the problem single "booking" post, see here:
https://old.sshcorporate.co.uk/wp-admin/post.php?post=948&action=edit

There isnt' any custom field that is using name "driver-allowed" , "driver allowed" something like this.

So there isn't custom field "driver-allowed" in the single "booking" post, as a result, the shortcode [types field='driver-allowed'][/types] will not output anything in the front-end.

If you are going to display the field value from other post/page, you can specific the "id" attribute of the Types shortcode, for example:
[types field='driver-allowed' id="12345"][/types]

More help:
https://wp-types.com/documentation/customizing-sites-using-php/functions/
Attribute "id":
"$parent" | "post-id" | "$custom post name"
http://wp-types.com/documentation/user-guides/displaying-fields-of-parent-pages/
Displaying Fields of Parent Pages

And please create new thread for the new question, that will help other users to find the answers. thanks

Viewing 7 posts - 1 through 7 (of 7 total)

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Known issues and their solutions

We document known issues and their solutions in Toolset erratas. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.

Support Policy

Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

For more information, read our full Customer Support Policy.

Need custom programming work for your site? Check out our certified partners.