Skip to content

Instantly share code, notes, and snippets.

@Anubarak
Created May 29, 2020 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anubarak/090a333d8c01b1567f48b99c1be1259d to your computer and use it in GitHub Desktop.
Save Anubarak/090a333d8c01b1567f48b99c1be1259d to your computer and use it in GitHub Desktop.
$model = new DynamicModel($request->getBodyParams(), [
[
['firstname', 'lastname', 'mail', 'privacy'],
'required',
'message' => Craft::t('site', "Folgendes Feld Fehlt: {attribute}")
]
]);
$model->addRule('minEntryTimeMethod', static function() use ($model){
if (/* kleiner als 3s */) {
$model->addError('title', "Sie haben zu schnell abgesendet");
}
});
$model->validate();
$model->getErrors();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment