Skip Navigation

[Resolved] Custom Field Default Value not working

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2603863
Screen Shot 2023-05-08 at 1.51.06 pm.png

I have a Number Custom Field with a Default Value set to 0. (I have also tried other numbers, like 1 and 10 with the same effect).
When I view that field in the Custom post on the backend it shows the value there, but when accessing this number via a Condition, it is actually empty. If however you edit and save the custom post containing the field in the back end it seems to save the number and it now works via a Condition (even if you just edit other fields, and not the number field itself).

How do I fix this as I need that default number to work without having to edit the posts in the backend first.

thanks

#2603995

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

It seems you misinterpreted how default value works.

The field only has a value when you save the post. If no value is entered, then the default value is saved. That is what is meant by default value. It doesn't mean that the post already has a value for that field equal to the default value.

That is why you see the condition is working when you save the post and this is working as expected.

#2604199

But when the data is saved from the front end form it isn't updated either, only from the backend.
How do I get it to update when the front end form is saved?

Also, when you view the data in the Custom Post in the backend it shows the number there - why show a number there that isn't ACTUALLY there - that should not show a value there if that value is not actually what is usable. That is a bug (or bad design).

thanks

#2604233

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

But when the data is saved from the front end form it isn't updated either, only from the backend.
How do I get it to update when the front end form is saved?
==>
You can either set the default value or you can use the Toolset form hooks like "cred_before_save_data" or "cred_save_data" to set the default value for the field.
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

Let me know if you need any help to set the default value for your custom field using Toolset form.

Also, when you view the data in the Custom Post in the backend it shows the number there - why show a number there that isn't ACTUALLY there - that should not show a value there if that value is not actually what is usable. That is a bug (or bad design).
==>
That shows the default value so when you save the post in backend the default value will be get saved. This is by design.

#2604589

That shows the default value so when you save the post in backend the default value will be get saved. This is by design.

-- It would be nice if there was some way you could differentiate a value that is actually there vs a value that will only be there IF you save the post. (maybe greyed out, or an asterisk ?)

thanks

#2604613

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

There is no such feature available as of now but I'll pass your comment to our next level support and will discuss on it and if anything gets approved accordingly we will file internal ticket for the same to improve this feature.