- This topic has 2 replies, 2 voices, and was last updated 5 years ago by
Steve.
-
AuthorPosts
-
-
January 9, 2017 at 8:11 pm #7711
johnvanhamParticipantHello,
I have attempted to write a custom validation rule to check that at least one field out of two fields is filled in. The requirement is for the user to have to enter data into either field or both but not both of them left blank.
I started by basing my validation rule on the ‘match’ rule which compares two fields which I found in the Piklist_Validate class.
However, after much head scratching I have discovered that Piklist does not run validation on fields if there is no value in the field.
The form is saved using a custom scope via the action hook piklist_save_field-{$scope}. This runs at the end of Piklist_Form::save(). Is there some way I can in my action add my own field errors for the page to render since it looks like I cannot use a validation rule or callback?
Or is there some other workaround? I don’t want to have to edit the Framework to achieve what I need ideally.
Thanks everyone!
-
January 9, 2017 at 8:23 pm #7712
johnvanhamParticipantWhat I’m running into is line 686 in the Piklist_Validate class (version 0.9.9.9) which checks whether the field has a request value before calling the custom callback function (if one is set). Is there a reason this check is needed?
-
January 17, 2017 at 5:41 pm #7732
SteveKeymaster@johnvanham– We can look into this, but just a thought. Maybe insert some default text in the field. Something you would use instead of placeholder text.
-
-
AuthorPosts
- You must be logged in to reply to this topic.