Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new 'Category' field to database #365

Open
GelLiNN opened this issue Nov 9, 2018 · 5 comments
Open

Adding a new 'Category' field to database #365

GelLiNN opened this issue Nov 9, 2018 · 5 comments
Assignees
Labels

Comments

@GelLiNN
Copy link

GelLiNN commented Nov 9, 2018

Hi phproject!

I've had some great success customizing this application so far, but I'm running into a headache with trying to add a new issue field to the database and the application as a whole.

I'm adding a new 'category_id' entry to the issue table, and a new 'issue_category' table with int IDs and category names. I have 5 categories and I'm going to add the ability to filter by those to the issue browser.

I have already changed the database.sql file to include these new changes and it works great, and have also changed the edit-form.html view to include a dropdown for selecting category, which populates from the database correctly.

The problem is that when I create the new issue or attempt to edit/update the issue, the new category does not make its way into the issue table. Also, on the single.html view when I attempt to display the category with @issue.category it comes back with a 500 field does not exist error.

Any fixes for this or help on implementing these categories would be greatly appreciated!
categories4
categories3
categories2
categories1

@Alanaktion Alanaktion self-assigned this Nov 9, 2018
@Alanaktion
Copy link
Owner

Due to a limitation in the Fat-Free framework, the code for the most part doesn't directly use any SQL JOINs in the model system. Because of that, we use a View instead of joins to get the additional issue data, but the view has its own defined set of columns to display. You'll need to update the issue_detail view in your database to include your new category column, then it should work everywhere.

@GelLiNN
Copy link
Author

GelLiNN commented Nov 9, 2018

Thanks for the tip, I added the update to the issue_detail view to support the new field. However, now when I create the issue the database still is not updating and now the single.html view isn't rendering correctly and not displaying an error message either.

Here's the commit, maybe you will know what's causing this strange behavior on the client-side?
Building-Intellect/BI-projects@859ee61

Maybe the field has to be non-null? Or maybe something else with the way the fields are being saved in the db from the controller.

@GelLiNN
Copy link
Author

GelLiNN commented Nov 9, 2018

UPDATE: I had the wrong name attribute on the form, and after fixing that the db auto-inserts the new category_id into the issue table. However, the single issue detail page is still just coming up blank and I have no idea why.
category

@Alanaktion
Copy link
Owner

This could be a side effect of caching. Try clearing the cache from the Administration panel. If that doesn't work, check the PHP error logs, which should have more detail on what's going on.

@GelLiNN
Copy link
Author

GelLiNN commented Nov 12, 2018

Okay I tried clearing cache and that didn't work, so I looked at the PHP error log and it's getting an "undefined field category" on $this->_render("issues/single.html"); in the single() method in the issues controller. Here's the callstack:
[12-Nov-2018 22:35:59 UTC] Undefined field category [12-Nov-2018 22:35:59 UTC] [vendor/bcosca/fatfree-core/magic.php:85] DB\SQL\Mapper->get() [12-Nov-2018 22:35:59 UTC] [tmp/1y6t2lfaoikg0.38cruea1dj40g.php:133] Magic->offsetget() [12-Nov-2018 22:35:59 UTC] [tmp/1y6t2lfaoikg0.3u184if14tq8s.php:15] Preview->render() [12-Nov-2018 22:35:59 UTC] [app/controller.php:74] Preview->render() [12-Nov-2018 22:35:59 UTC] [app/controller/issues.php:798] Controller->_render() [12-Nov-2018 22:35:59 UTC] [index.php:146] Base->run()

After looking up the error online I haven't found anything. Any idea what could be causing this given the new info?

Thanks again man, here's a link to my current codebase if you want to chase anything down:
https://github.com/Building-Intellect/BI-projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants