Home › Toolset Professional Support › [Closed] Custom field of type "URL" not validating field entry
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 12 replies, has 2 voices.
Last updated by Minesh 1 year, 11 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
I created a custom field of type "URL" with the expectation that the field would validate entries as being a valid URL of the format "hidden link" or "hidden link". Unfortunately, it appears that no validation is actually done to field entries and anything can be entered. Values with "hidden link" or "hidden link" are treated as external links (as expected) while plaintext entries are treated as subdirectories of the current form URL (unexpected).
Is there any documentation that you are following?
None that I can easily find...
What is the link to your site?
hidden link
Is there any way to include a custom field validation to solve this issue?
Thanks!
Hello. Thank you for contacting the Toolset support.
Where exactly you are trying to validate the URL field - is it in the backend admin or using the Toolset form?
Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/
I am expecting validation to occur on a front-end form (the form is only available to logged-in users, though).
Can you please share problem URL where you added your form and admin access details and also that what URLs you want to validate with what field.
Please share admin access details and frontend user access details (if required).
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I can see you are using multiple URL fields:
To validate the URL field - you can use the Toolset form hook "cred_form_validate" and validate the user input.
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
You can validate URL field value using following:
=> hidden link
If you can share more details what fields you want to validate with that form and what form of input should be given is valid and not valid I would be happy to share you the solution.
My expectation was that a custom field of type "URL" would, by default, validate that any field entry was in fact a valid URL. Apparently, that is not the case and any string entered into the field is allowed.
As you found, I have multiple custom fields of the type "URL". One is a generic URL field which I merely need to validate that the entry is a "fully qualified domain name" (e.g., hidden link or hidden link). Other fields are specific to social media platforms and should validate as necessary for the associated platform (e.g., for Facebook the field entry should be hidden link).
Toolset URL field checks for http:// or https:// and domain.
Here is a sandbox site and you can auto-login to it using the following link:
- hidden link
With the following post - you can see the URL field under the "Social media" repeating field group and you can try to validate.
For custom validation requirements like you have for facebook field or any other URL field you will have to validate it using the Form validation hook "cred_form_validate":
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
This does not happen on my site. Any string of text can be input in a "URL" type field. When a "URL" type field is displayed on the front-end, the field entry is either treated as a subdirectory of the current domain (e.g., field contains "random" which is then displayed as a link to hidden link) or as an external link if http:// or https:// are included (e.g., field contains "hidden link" which is then displayed as a link to hidden link).
Not sure what is different about how this is implemented on my site, but it certainly does not work as you describe above...
As shared you have custom validation required so you will have to use the Toolset Form validation hook: cred_form_validate
I'm not sure why URL validation is not available with your URL custom field on custom field group edit page. When I try to add a new URL custom field or even with existing I can see there is a URL validation available. Please check the following screenshot:
-hidden link
If you see your URL custom field I'm not sure why URL validation is not available. Rather then digging too deep in that I suggest you should use the form validation hook "cred_form_validate" and add your required validation.
It isn't clear from the documentation you linked how to use cred_form_validate for URL validation. Is there a more detailed explanation of how this is used with Toolset forms?
FYI, this was a clean/new install of Toolset so there may be something broken with the current Toolset install that is causing the URL validation option to not appear when creating/editing a form.
Thanks!
It isn't clear from the documentation you linked how to use cred_form_validate for URL validation. Is there a more detailed explanation of how this is used with Toolset forms?
==>
We do not have any other resource but if you want I can help with that but for that you will have to share all information about what fields you want to validate and what validations you want to apply.
FYI, this was a clean/new install of Toolset so there may be something broken with the current Toolset install that is causing the URL validation option to not appear when creating/editing a form.
==>
I'm not sure as with the sandbox site I shared with you there is a URL validation available on custom field group page and the same is not available on your install. Maybe you can try to reinstall the Toolset plugins and check if that helps or try another server.
What information do you need on the fields needing validation?
To what custom fields you would like to apply the validation and what validation you would like to apply.
The topic ‘[Closed] Custom field of type "URL" not validating field entry’ is closed to new replies.