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

StackOverflow https://stackoverflow.com/questions/13374754

  •  29-11-2021
  •  | 
  •  

Question

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:

Model Generation

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

Voucher.php

Step 2: CRUD Generation:

CRUD generation

Workaround:

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

workaround

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.

Was it helpful?

Solution

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

OTHER TIPS

I noticed that same name in class name due to anothe error too.I prefer avoiding create Class with the same name in yii.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top