Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Extend PHP Validation to validate required fields by custom rules #131

Open
wilr opened this Issue · 6 comments

3 participants

Will Rossiter tazzydemon Jyrki Lilja
Will Rossiter
Owner

From #116

Create textfield test.
Create new textfield test1. Mark it required & set it to hide by default.
Add custom rule to test1: Show This Field When test is Value test

Try submitting the form with field test set to check. The form won't validate. Now set it to test. Field test1 appears correctly. And if it is unset, the form won't pass validation. Setting test1 validates the form.

tazzydemon

Any progress on this issue which has reared its ugly head with me. I'm almost prepared to put up with no php validation at this point,.

Will Rossiter
Owner

No progress on it from me. Happy to review patches if you want to give it a go. If you want to disable PHP validation you may as well make the field not required and just put (required) as a label text or something.

Jyrki Lilja

If I'll try patching this at some point where should I start my searches for PHP side of validation. As I mentioned in #116 I couldn't find the place then...

Will Rossiter
Owner

The PHP side of validation uses the normal SilverStripe API. See UserDefinedForm::getRequiredFields(). One way would be to not use the core SilverStripe validate() method on form fields and manually invoke validate methods in the submit form method.

tazzydemon

Since I just failed so spectacularly on identifying a jquery validation error, ironically because of this, I was wondering if anybody had any more to offer. I cant see a way round it other than to not require the conditional fields and the client is demanding that they are required. A problem and perhaps time for another custom form!

Will Rossiter
Owner

@tazzydemon What I would aim to do is ticking that required box in the cms didn't actually set the PHP required fields and validation is controlled after the rules are parsed in the form handler. I'm keen to build this when I can get around to funding it, if you want to tackle it PR's welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.