Skip Navigation

[Resolved] Limit number values to add to a Types Number Field

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

Problem:
Can we limit the numbers that one can add to a Types Number Field?
Like, only 1-10 or so?

Solution:
No.
This would require Custom Code.

This support ticket is created 7 years, 10 months 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by mikes-23 7 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#424482

I have added a number field to my custom post type. This adds a text box where user can enter anything but I want to control the range of numbers.

In pods they use sliders which is perfect. I can select range of slider then user in admin when creating new post type can use the slider to select the correct number.

How do I do the equivalent in toolset?

#424551

It's not possible with Toolset native features.

The Number field lets you add any number (also decimal or such) manually, ba typing them into the field.

A validation or range would have to be done manually, using Custom Code applied to the save_post action:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

This would require Custom Code.

A possibility is to use CRED, where you can apply a CRED Filter that would then filter the Posts field on submission for the value and return an error in case it does not match your criteria:
https://toolset.com/documentation/user-guides/cred-api/#cfv

#424994

Thanks for confirming. I validated with my own code.

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