Forum

Thread tagged as: Api, Add-on-development

Validate Custom Field

Is there any way to implement validation on a custom field and prevent the page from saving?

Toby Martin

Toby Martin 0 points

  • 1 week ago
Drew McLellan

Drew McLellan 2633 points
Perch Support

Yes! Use a validation helper

https://docs.grabaperch.com/api/validators/

My understanding was that these were for public facing forms, not custom fields types in the control panel?

Drew McLellan

Drew McLellan 2633 points
Perch Support

Oh sorry, so by custom field do you mean custom field type? If so, hmm, I'm not sure.

What's the scenario you're trying to solve?

Yes that's correct, I have a few field types that I would like to work on.

The first (and most simple) being a url field type, as I've long thought this would be good to have, but I wasn't able to see anywhere in the docs about validating field types. In this instance, I just need to make sure that it's a fully qualified link. I'll be adding some js validation in there but would good to do this server side too.