Is there any way that within Toolset I can configure a URL Custom Field to be "pre partly filled"?
For example, imagine I had a Custom Field called "Twitter Link". I would only want to accept URLs in this Custom Field that are within the domain of "twitter.com".
I was either thinking is there a way within Toolset where the domain can be pre configured so that the domain is pre filled and cannot be changed (in this case it would be twitter.com) and only the URL after this can be entered?
Either that or is there a way to validate a URL that is entered so that it must belong to a specific domain? For example, in this instance, any URL that is not twitter.com would be rejected.
I would be very grateful if there was a solution to this!
I hope I have explaining this well enough. If you need anything else explained then please just let me know.
1. You can, of course, create a single line field and let users insert only what you want there (for example, all after twitter.com)
2. Then you just create a Content Template, insert that Field, and prepend it with a hardcoded string (twitter.com).
Something like this:
<a href=twitter.com/[your_types_field_shortcode_here_output_as_RAW]/">Link Text</a>
3. Or you can validate with a Custom Snippet that either checks on save_post action (WordPress action when you save the post in the backend) or cred_save_data or any validation hook of Toolset Forms as shown here:
https://toolset.com/documentation/programmer-reference/cred-api/
The simplest, and not needing any code at all, is the option with hardcoded twitter URL and partial URL submitted by Users.
We have requests for adding REGEX and other validation to fields.
I would suggest you submit this request you have here as well (to validate URL's domains) here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Thank you Beda!
That first solution was perfect.