Viewing 2 reply threads
  • Author
    Posts
    • #7711
      johnvanham
      Participant

      Hello,

      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!

    • #7712
      johnvanham
      Participant

      What 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?

    • #7732
      Steve
      Keymaster

      @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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.