简体   繁体   中英

yii framework's CRUD generator (gii) shows error message : “'Voucher' must extend from CActiveRecord.”

I am trying to generate CRUD for my vouchers table using gii,I follow simple steps through which I always generate CRUD but this time with "vouchers" tables its showing some unexpected error message

'Voucher' must extend from CActiveRecord.

Below is how I am trying to generate the CRUD.

Step 1: Model Generation:

模型生成

Her is generated voucher model located in root/protected/models/Voucher.php

Voucher.php

Step 2: CRUD Generation:

CRUD生成

Workaround:

I tried to generate CRUD with path alias for model class and it works, have a look at screen below

解决方法

About workaround solved the problem but I wonder why CRUD generator is not generating the CRUD as normally it does with all other model names. I noticed that it shows this error only for "Voucher" model and for this specific model I have to go for above workaround.

I noticed that there is a class named 'Voucher' in root/protected/components/ folder that is causing above problem. Renamed it and issue resolved!

我也注意到由于错误而在类名中使用了相同的名称。我更喜欢避免在yii中创建具有相同名称的类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM