Skip Navigation

[Resolved] Select doesn't save post data

This support ticket is created 2 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by michielM 2 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2358947

On an edit form page of a custom post type, I have a view that generates the values for a select field. This works fine now (see https://toolset.com/forums/topic/view-as-select-not-working/ for more information). However, when I click submit to store the chosen value, it doesn't do that.

I would like to see the chosen value stored in the CPT and to show the chosen value after the save in the select field (also when I revisit this specific post).

#2359075

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I see with the following view you are using title as both value and label. Instead of using title as value, we need to change it to use ID.
=> hidden link

So first step is, I've change the view's loop that offers the select option where I've change the value to use ID, so we will have ID and label pairs:
=> hidden link

{"value":"[wpv-post-id]","label":"[wpv-post-title]"}

With the form, I've adjusted the generic field name as: field='wpcf-workshop-leerling-locatie'
=> hidden link

 [cred_generic_field type='select' field='wpcf-workshop-leerling-locatie' class="form-control"]
            {
          	"persist":1,
            "required":1,
          	
          	"options":[ [get_generic_select_options] ]
            
            }
          [/cred_generic_field]

As you can see to save the generic field value, I've added the attribute:

"persist":1,
  

Can you please confirm it works as expected now:
- hidden link

#2359207

Great, Minesh!

Just one more thing: the chosen value doesn't show after saving it (submitting the form), it always goes to the "--- not set ---" value even when it had a value to begin with.

To see this in action: just click on "Opslaan" and you will see the green message that the Workshop has been saved, but the value will be set to "--- not set ---".

Thanks for you help!

#2359211

On a side note, according to this forum post "persist" is deprecated since 2016:
https://toolset.com/forums/topic/cred-generic-field-does-not-work-with-persist/#post-625852

*edit
Oh, as an argument probably, but not as what you insert between the tags. Where's the documentation on that? I can't seem to find it.

#2359497

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

There is not much Docs available related to Generic fields. All we have is the following Doc:
- https://toolset.com/course-lesson/adding-generic-fields-to-forms/

#2359619

My issue is resolved now. Thank you!