In cakephp 4, in the case of a form with Model Table I use the callback method ModelTable::beforeMarshal()
to trim()
data before validation, but where can I do that in the case of a Modelless Form ?
There's no events/callbacks for it, there's only Form.buildValidator
, but this only applies when validation is actually happening, and on top of that, only when the buildValidator()
method has been implemented.
If you want to do it generally, and before validation, then you could for example override \Cake\Form\Form::execute()
:
public function execute(array $data, array $options = []): bool
{
// modify $data here
return parent::execute($data, $options);
}