Saltar navegación

[Resuelto] How to «set» the value of an invisible checkbox field in a form?

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

Set the default value to "checked" on checkbox field of Toolset post form.

Solution:

You can try the attribute "value" of shortcode [cred_field], for example:

In "Featured Ad" post form, use below shortcode:
[cred_field field='featured_ad' ... value='1']

Relevant Documentation:

https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_field

This support ticket is created hace 4 años, 9 meses. 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
- 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/Hong_Kong (GMT+08:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por PaulS4783 hace 4 años, 9 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#1583581

On this page:
enlace oculto

This is the submission form for creating a STANDARD vehicle listing on a car directory site.
There will be two "tiers" of directory listing.
One is for a Standard Ad and another for a Featured Ad.
I have two different WooCommerce "products" attached to the two different submission forms.

The custom post type "Listings" has a custom checkbox field for "Featured".
Default is unchecked.

How can I set up the form so that :
a) this field input isn't shown to the user.
and
b) set the default value to "unchecked" for the Standard Ad Listing submission form.
and "checked" on the equivalent Featured Ad Listing submission form.

See below:

enlace oculto
enlace oculto
enlace oculto

#1583809

Hello,

You can try the attribute "value" of shortcode [cred_field], for example:
In "Featured Ad" post form, use below shortcode:
[cred_field field='featured_ad' ... value='1']

Above shortcode will preset the "featured_ad" field value to 1, and setup the checkbox as "checked".

Then use CSS codes to hide "featured_ad" field.

See our document:
https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_field
value. Optional. Preset value

#1584537

Awesome. Solved.

Ideally, there would be a better way than using CSS to create a "hidden" field though.
Anybody with better than intermediate CSS skills could potentially over-ride the "display:none" settings in the source code if they knew what to look for.

Gravity forms has a "hidden field" feature but I'm not sure how they implement it.

You can close ticket.