Skip to content

Instantly share code, notes, and snippets.

@Anubarak
Created May 29, 2020 07:20
Show Gist options
  • Select an option

  • Save Anubarak/090a333d8c01b1567f48b99c1be1259d to your computer and use it in GitHub Desktop.

Select an option

Save Anubarak/090a333d8c01b1567f48b99c1be1259d to your computer and use it in GitHub Desktop.

Revisions

  1. Anubarak created this gist May 29, 2020.
    15 changes: 15 additions & 0 deletions DynamicModel.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    $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();