Welcome Guest, Not a member yet? Register   Sign In
Creating a custom service/library
#3

(02-05-2020, 08:30 AM)x1250 Wrote: Assuming you define validationRules in the model, you need to use something like the following in your controller method:

PHP Code:
    if (!$this->validate($model->validationRules)) {
      $errors $this->validator->getErrors());
      //... do something with the errors array.
    

Thanks for your reply. This is a solution, but is not the one I am looking for. I guess if I take a more generic example (and please assume I'm a newbie) it may illustrate where I'm struggling.

I want to create a new class that has its own properties and methods, but has nothing to do with the tables in my database. Do I still create it as I would any other model, or should I use a service/library? If it is a service/library a very short example would help, because I'm struggling to understand how to do it from the documentation.

Apologies if this comes across as a remedial quesion.
Reply


Messages In This Thread
RE: Creating a custom service/library - by x1250 - 02-05-2020, 08:30 AM
RE: Creating a custom service/library - by Fido L Dido - 02-05-2020, 09:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB