Yii 2 exist validator


I am using the following validator …

["fkIDWithFileID", "exist", "targetClass" => "File", "targetAttribute" => "name"],

I get the following error …

exception ‘yii\base\ErrorException’ with message ‘Class ‘File’ not found’ in /home/mutabl3/public_html/jamesbarnsley.com/showcase/email-download/vendor/yiisoft/yii2/validators/ExistValidator.php:155 Stack trace: #0 [internal function]: yii\base\ErrorHandler->handleFatalError() #1 {main}

I have also put …

use app\models\File;

At the top, I do not know whether I needed to "use" it or not but its there anyway just in case. Anyways I am getting the error and I do not know why?


Put the fully qualified name into the targetClass field: "\app\models\File"

It works! thanks for your help.