Use of dynamic validation via Validator with FormHelper CakePHP 3.x


I am creating a ‘form editor’ in CakePHP.

The interface allows the user to choose validations to apply to the fields, e.g. Numeric, Email etc.

As such I need to dynamically create validation for the model based on the user input. For this I can use the Validation object:

I want to take advantage of the features of FormHelper, for example, automatically outputting error messages for fields.

I can see how to use a hard-coded validator from the model to do this by setting the validator in the context option for Form->create() - but how do I use a custom $Validator object which has been dynamically created?

Clarification: I am creating the validation object in the controller as I need to use a url parameter to load the correct configuration. I just don’t see how to get the table to use my dynamically created Validator object.