DialogFormDocument: How to use validation?

  • Hello,

    I am trying to create and validate a form using DialogFormDocument. The form gets created during a method in a class inheriting AbstractDatabaseObjectAction. This method furthermore gets called by using the WoltLabSuite/Core/Form/Builder/Dialog.

    My problem is that the FormFieldValidator never gets called and the input therefore never gets validated. The documentation does not state out any information about the validation process using DialogFormDocument.

    I've tried to store the form in a class variable (and then call validate()) instead of a local one but as the class gets new instantiated during the submittment of the form the created PHP dialog is not available anymore.

    So what's the correct way? What am I missing?

    • Official Post

    The form document will be created twice: During the request for the form and during the request submitting the form data (just like in normal forms). You can simply add a lazy getter to the class that returns the form document object and call this getter in the getDialog() method and the validateSave() method (where the validation call should occur).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!