Skip Navigation

[Resolved] Hide the custom fields in a Form and keep the value after save

This thread is resolved. Here is a description of the problem and solution.

Problem: I have defined a custom field in my Form and set its value using a URL parameter. I would like to hide that field on the front-end, but if I use HTML comments the field value is not saved. How can I hide the field but save the value from a URL parameter?

Solution: Use CSS to hide the field itself or a container element:

<div style="display:none;">[cred_field ...]</div>

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

This support ticket is created 3 years 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1984873
Screenshot 2021-03-13 at 7.50.13 PM.png

Dear Sir/Madam,

Q1: I will pass a urlparam value to a field in CRED form, I don't want to show it in frontned, how can I hide it but not using <!-- -->

Q2:I set the After visitors submit this form: to Keep displaying this form and enable Submit this form without reloading the page (use AJAX), after I save the form, the field getting value from urlparam gone, how can I keep it?

Q3: There is a table, I want to show it after saving the form but not show both together.

Q4: The table repeatedly be duplicated if I save the form
here is the form

[credform]
[cred_field field='application-tour-number' force_type='field' class='form-control' output='bootstrap' urlparam='tour-id']
...
...
[/credform]

<form id="register" method="post" action="update.php">
	<input type="hidden" name="action" value="register">
  </div>
...
...
</form>
#1986259

Q1: I will pass a urlparam value to a field in CRED form, I don't want to show it in frontned, how can I hide it but not using <!-- -->
You can use CSS to hide a field but keep it in the form submission:

<div style="display:none;">[cred_field ...]</div>

Q2:I set the After visitors submit this form: to Keep displaying this form and enable Submit this form without reloading the page (use AJAX), after I save the form, the field getting value from urlparam gone, how can I keep it?
Default values from URL parameters only work upon page load, so it is usually best to reload the page (no AJAX) when submitting the Form if you want to use URL parameters for default field values. Otherwise, you need a custom JavaScript solution that reads URL parameters and sets the default field values when the AJAX submission is complete. The problem is there is no JavaScript API for Forms, so there is no JavaScript event hook like cred_submit_complete for these AJAX events.

Q3: There is a table, I want to show it after saving the form but not show both together.
"Not show both together" If you don't want to show both together, why are they both on the same page? Why not put the Form on one page and put the table on another page? And redirect from the Form to the page with the table?

Q4: The table repeatedly be duplicated if I save the form
I'm confused. You said you don't want to show both together. Can you explain a bit more?

#1986327

Dear Christian Cox,

Thanks for your reply. Refer to the screenshot, the lower table will be shown once the CRED form saved, this is what I mean don't want to show both together before save.

I think you answered from https://toolset.com/forums/topic/add-repeatedly-relationship-custom-post-at-frontend/#post-1986325, let's continue discussing there.

#1987097

I think you answered from https://toolset.com/forums/topic/add-repeatedly-relationship-custom-post-at-frontend/#post-1986325, let's continue discussing there.
Sure, I will close out here and we can continue in the other ticket. Thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.