Search code examples
javagroovycontent-management-systemcrafter-cms

In CrafterCMS, how can I add a number control that validates a certain range?


I have a Google Maps component where authors can specify a latitude and a longitude.

I'm using a regular "Input" type control with a regex that validates if they are numbers, but, when trying to approach the problem of specifying a range (have the longitude verify that the value is within [-180, 180] and latitude within [-90, 90] )

However, having this validation through regex seems cumbersome, plus it would be nice to leverage input type="number"


Solution

  • You can make your own Form control following this http://docs.craftercms.org/en/3.0/developers/extending-studio/form-engine-control.html?highlight=control%20form