Home › Toolset Professional Support › [Resolved] Hide necessary fields in forms automatically generated
Problem: I would like to apply a value to some form field and hide that field from the User.
Solution: Use CSS to hide the field, or use a generic hidden field with the default attribute defined by a hard-coded value or shortcode.
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)
Tagged: Content-submission forms, CRED API, Toolset Forms
Related documentation:
This topic contains 4 replies, has 2 voices.
Last updated by fabriceS 4 years ago.
Assisted by: Christian Cox.
Hi !
I've created a form to ask informations about a product in the product page.
I have add the default value [wpv-post-title] in the form name field so I can clearly identify it in the back-end list of form entries.
So I need to have this "form title" field but I do not want to display it as it is an "internal" field filling.
Is there a way to do that cleanly differently than "display:none" ?
Hello, hiding the field with CSS is the probably the simplest solution. In the Expert mode Form builder, you can set the field to be readonly if you'd like, to prevent field modification. You could add a generic hidden field to the Form that contains the desired title, and remove the original post title field from the Form (expert mode may be required here). You can also remove the post title field entirely and use a custom code solution to copy the original post's title into the Form submission title automatically if you're comfortable customizing PHP. I can show you some examples of how that might work. Let me know if you'd like more information about that, or if you think the CSS solution or generic hidden field solution is sufficient.
Hi Christian !
Thank you for your reply. I'm more and more comfortable with the expert mode but not with php 😄.
Actually is there a way to give a value to a field of the form hardcoded in the expert-mode (but not in php). Tell the system Variable X= Value Y without being a field to manually fill ? If not, the CSS solution will be the one otherwise I would prefer it cleaner...
Yes, this is possible in expert mode. You can provide a value for any cred-field or shortcode using the value attribute in its shortcode. That value can be hard-coded, like this:
[cred_field field='post_title' class='form-control' output='bootstrap' value='Some arbitrary title']
Or, you can pass in the value from a Types field shortcode or any other custom shortcode you have registered in Toolset > Settings > Frontend Content > 3rd party shortcode arguments:
[cred_field field='post_title' class='form-control' output='bootstrap' value='[types field="your-custom-field-slug" output="raw"][/types]']
If it's a Types custom field, you should probably use the output="raw" attribute as shown in the above example to prevent HTML conflicts.
If you're using a Forms generic field, the syntax is a bit different. You can supply a default value in the "default" attribute of the field configurations, like so:
[cred_generic_field type='textfield' field='generic-field-slug'] { "required":0, "default":"Some arbitrary value" } [/cred_generic_field]
...or with a shortcode:
[cred_generic_field type='hidden' field='your-field-slug'] { "required":0, "default":"[types field='your-custom-field-slug' output='raw'][/types]" } [/cred_generic_field]
If there is some other implementation you need more information about, please provide more details.
My issue is resolved now. Thank you!