Forum

Thread tagged as: Question

Form validation - Checking supplied reference code

Hi,

I'm building a form using Perchs form app and I would like to be able to check a supplied reference code to ensure the person posting the form is allowed to.

To supply some context, this form is for RSVP'ing to a wedding and an RSVP code has been supplied on the invite that the person needs to input on the form when filling out the rest of the details, in order to prevent unwanted guests / spam form submitting the form!

Is this possible to do in the form app or do I need to build some custom code??

Thanks,

Alex

Alex Tebbutt

Alex Tebbutt 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to write some code - a validation helper.

Create a class with a static method that accepts the value from the field and returns true or false.

Add your helper to your field with:

helper="MyClass::my_method"

Hi Drew,

Thanks. How would I include a new class / object, is there a way to extend an existing perch class, any documentation about this you can point me towards?

Thanks,

Alex

Drew McLellan

Drew McLellan 2638 points
Perch Support

There's not a formal way yet. You could include it from your config.php or apps.php file.