tombenner/wp-mvc

What does generate in command line actually do? Solved: Field x not found for use in a form input

Closed this issue · 7 comments

Firstly, thank you for this project.
I'm trying to follow the tutorial but my DB table doesn't have an id or a name. My primary key is InfoId and even though I changed in the view's admin's add.php to this code, and anywhere that references id to reference InfoId, I still get Field InfoId not found for use in a form input when I try to add an item in the admin view. What am I not understanding and how do I get over this error? Thank you.

Took 2 hours to find the fix.

Found after trying to create another plugin to understand the example code in WP MVC. When ran the generate plugin command, got WordPress database error Table 'bitnami_summit.wp_qr_screens_infos' doesn't exist for query

Found out that my DB name had to match the naming scheme. I used DB name QrScreensInfos. It needed to be qr_screens_infos.

New question: What does generate do that allowed this error to show? Maybe have another command to allow these diagnostics to be ran so that these problems regarding naming mismatch can be located more easily?

Some more notes: I think there are bugs because it seems like sometimes the model name will be truncated incorrectly.
I tried using model name DemoModel and the name got truncated to just Demo. The table it wanted to wp_demos instead of wp_demo_models.

I saw this issue with models named DemoModel, MyModel

Yes, table doesn't exists IS very clear and that was what pointed me to finding out that I had a name mismatch. However, what I was trying to say was that I found that out after I got frustrated and ran the generate scaffold command in command line, which isn't very intuitive. Before that, I kept on getting field not found error, when I know the field exists.

I'm actually going to close this request because instead of having naming-convention diagnostic via the command line, I found that being able to debug problems related to naming-conventions is more useful. I created a video on how to debug problems like this here, just in case it helps someone down the road: https://www.youtube.com/watch?v=XIef1H-clMQ&list=PLkrUNq1sQFX7N3BNzg2Xv9T5ijdy05YkC&index=2