Skip Navigation

[Resuelto] Conditional output based on post field values instead of form values

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

Problem:
Conditionally include content in a Toolset Form based upon field values from another post.

Solution:
Use the wpv-conditional shortcode and insert the shortcode for the field in question in the condition.

Then manually edit that generated shortcode and include an id attribute to specify which post should be the source of the field value.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

This support ticket is created hace 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 respuestas, has 2 mensajes.

Last updated by herreV hace 5 años, 9 meses.

Assisted by: Nigel.

Autor
Mensajes
#916139

Hello,
not sure if this is possible...

What i'm trying to do is to create a CRED form that only displays certain fields based upon conditional output .... but the conditions are not field values in the form itself... but values of other posts based upon an post id...

EXAMPLE:

[cred_show_group if="('[types field="status" item="217263"][/types]' eq  '1' )"  mode='fade-slide']
	<div class="form-group">
		<label>[types field='title-heading' item='217263'][/types]</label>
                [types field='content' item='217263'][/types]
		[cred_field field='t1q1' value='' urlparam='' output='bootstrap']
	</div>
[/cred_show_group]

What I would like to achieve is that when the value of '[types field="status" item="217263"][/types] equals 1 ... the CRED form will show form_group...

Is this possible?

#916199

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

Timezone: Europe/London (GMT+00:00)

Hi Herre

The conditional display using the cred_show_group shortcode in a Form is a browser-based solution that reacts to the value of a form input when it changes to update the visibility of whatever appears inside that shortcode.

Everything is present when the Form is rendered on the page. If a user changes one field, JavaScript shows or hides the conditional content.

You can use the wpv-conditional shortcode (https://toolset.com/documentation/user-guides/conditional-html-output-in-views/) which is evaluated while the page is being built and so determines what gets sent to the browser in the first place.

So if you only want to include some content in your form if a field from another post has a particular value, you can do that using wpv-conditional.

If you use the types shortcode to print a custom field value, you can add the id attribute to specify the id of the post the field should come from, as described here for example: https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

Does that cover what you need?

#919218

Sorry for my delayed reponse... I was fully occupied to other projects...

I will try your suggestion again, but for what I do remember is that CRED FORMS do not fully render the wp-v-conditional statements ... That somehow the shortcodes are even being displayed in the form instead of processing them...

I'll be back with my findings...

#919280

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

Timezone: Europe/London (GMT+00:00)

OK, let me know what you find, but I just worked on another thread where I proposed (after testing) a solution that uses wpv-conditional shortcodes and they worked as expected.

#920225

Hi Nigel,
Looks like I made a typo earlier before asking support... as indeed I used the same approach you suggested (and IO already tried 😉 ) ... and it does work flawlessly.

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