Skip Navigation

[Resolved] How to set default values for Toolset Form fields?

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

Problem:
A Toolset Form contains certain fields (custom fields or taxonomies) for which the client wants to set defaults.

Solution:
The fields are inserted in the Form using the cred_field shortcode. That shortcode accepts a value attribute to provide a default value.

You can use other shortcodes to provide the default value, the context for which will be the page where the Form is inserted.

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

This support ticket is created 6 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
- 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 12 replies, has 2 voices.

Last updated by meirk 6 years ago.

Assisted by: Nigel.

Author
Posts
#1165090

is it possible to pass atribbute arguments to a cred edit form to be used as a default value in a specific custom field?

#1165375

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

The fields in a Form are inserted using the cred_field shortcode, and that accepts a value attribute which can be used to set a default value: https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

You can set a value directly (e.g. value="10"), or using another shortcode. (The context for that shortcode would be the page where the Form is inserted.)

#1165824

i will explain better:
I am displaying an update form inside a post view.
I would like to pre-populate form fields with some variables i has in this view.
so i need to pass terms by the [cred_form form="add-cause-id-in-tehilim-post" terms????]
is it possible?

#1165847

Sorry, now i understand what you meant...
So the terms of my views (shortcodes) works well and are populated in the form.
But still i have a problem:
I have a repetitive field wich i want to add a new value to it and not just change its value .
How to do it?

#1166233

Any Ideas?

#1166243

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

This is a form to edit a post and it includes some existing values for repeating fields and you want the form to automatically add some new instances of the repeating field?

I can't see how you would do that, but let me confirm that is what you want first.

#1166261

bsd

Yes
just add one more value at each submit...

#1166304

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

"at each submit"

I thought we were talking about adding another repeating field instance when the form is loaded, but you mean add another instance after the form is submitted?

Where would the value of the new repeating field instance come from?

#1166308

sorry - english is not my native language
i mean exactly what you thought:adding another repeating field instance when the form is loaded

#1166403

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Let's make a concrete example that I could practically develop.

Say that the post type the form is editing has a simple single line text field "name".

The post being edited already has several instances of the name field, e.g. John, David, Elisabeth, and Joel.

When we click the button to be redirected to the edit form, the form loads and as well as the existing four names, we want to automatically add "Paul".

Questions:
- what page is the edit form button on (is it the post itself that is going to be edited, or something else)?
- how should the form know that the name to be added is Paul?
- is this visible to the user? Does it matter that if the name Paul is smuggled into the form invisibly, but is only added to the edited post once the form is submitted?

#1166861

"- what page is the edit form button on (is it the post itself that is going to be edited, or something else)?"
answer - right now it is in the post itself - or in a post view of the post.
- how should the form know that the name to be added is Paul?
answer = by an attribute in the form shortcode
- is this visible to the user? Does it matter that if the name Paul is smuggled into the form invisibly, but is only added to the edited post once the form is submitted?
answer - no it is not visible to the user - only the submit button will be visibel.

Thanks!

#1167913

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

I've been playing around with this, and I can't see a way to pass a value to a form.

Once the form has the value, everything else is reasonably straight forward, but I can't see how to get the value to the form.

Let me ask again in my hypothetical example, how should the form know that the name to be added is Paul?

You say "by an attribute in the form shortcode". Putting to one side that the form shortcode accepts no such shortcode, even if it did, how would you set the value of the attribute? Where does the value come from?

#1167962

Shalom
I needed this capability for a site that i am doing - but in a parallel ticket you gave me a new idea about how to bulid the data base and the relationships , in a way that right now i can go on without passing an atribbute by forms.
I think anyway it shoul be a good idea for next releases.
Thanks by now - i 'll continue in the other ticket in contact