I have figured out what I did wrong and how to fix it, but I don’t understand precisely why it happens.
When I used Gii to generate my models it worked fine. Then I generated my Ajax CRUD, but here I mis-named various parts of the puzzle.
According to this link (thanks, akhil!), I should have named my tables, models, controllers, and views differently.
For brevity, I’m only going to discuss the solution for training-description. The solution for food-preference is the same.
I deleted my database tables and my code models, controllers, and views and started over from scratch. I changed my migrations to use table names with underscores (for some reason Gii doesn’t like hyphens in table names):
training_description
then I used Gii’s model generator to create the models as:
frontend\models\TrainingDescription
Then I used Gii’s Ajax CRUD generator to create the controllers and views with these settings:
Model Class: frontend\models\TrainingDescription
Search Model Class: frontend\models\TrainingDescriptionSearch
Controller Class: frontend\controllers\TrainingDescriptionController
View Path: @frontend/views/training-description
Now, when I make a layout menu item pointing to the index page for training-description, it works!
Blockquote
[
‘label’ => ‘Training’,
‘items’=> [
[‘label’=>‘Training Types’, ‘url’ => [’/training-description’]],
[‘label’=>‘Food Preferences’,‘url’ => [’/food-preference’]],
],
‘visible’ => !Yii::$app->user->isGuest,
],
Thanks for your help, softark! Your advice led me to read the Routing and URL Creation Guide, which led to the solution.