the world of php CRUD systems -automatic relational database administration interface- is quickly moving forward : last month after weeks of buzz, NOVA the official crud tool made by PHP framework laravel founder came out, and it really looks nice, we all want to try it but there's small paywall that, even minimal (less than 100$ is nothing for that kind of tool), in the long term process, might stop opensource freaks like me to even try it.
So I was looking for good tool to work with, have tried backpack a few times, went withCRUDBOOSTER for a live project because I managed to set it up in a few minutes, when backpack would require a few more minutes, still very handy to set up. Note that even though backpack is freely available, it is a licensed products that will cost you, just like NOVA, a few bucks per year, but like NOVA it's worth the cost.
One big feature of BACKPACK, in comparision to CRUDBOOSTER, is its reliance on LARAVEL database model classes : this is really comfortable so for advanced projects because time you spend learning the model and relations ship conventions is a googd capital for future projects on any laravel based system. I went investigating and found there's a good hierarchical structure example in the form of news system management with categories, subcategories, and administration interface to work the hierarchy. This is something you might not easily manage with NOVA or any CRUD based quick development tool like Crud Booster, but on that particular point, BACKPACK for laravel did make a difference.
What's the problem : displaying hierarchical structures in edit form select boxes
in its original form, the select box for a hierarchical sortable field would display categories in form of an ordered list that would say nothing about the hierarchy.
Let's create a few categories , starting from the main "Good News" and "Bad News" categories, then going down to "Very Good.. Very Bad .." etc..
Backpack comes with a very handy feature, the possibility to reorder and nest records coming in the form of the following line in the entity controller :
this gives you access to a good looking hierarchical reorder interface, something like that :
But in its original form, when you go to work on news, the edit screen uses the select field (or select_multiple), which does not show the hierarchy, and that's really annoying :
We will have to create a new field type in backpack, that displays the categories within their chosen hierarchy and order:
How to deal with it : create new field type
A quick search on the subject led me to a very old discussion that deals with grouping records in the select field, and it is a very good approach but it onlys deals with one sublevel when BACKAPCK reordering and nesting feature allows any number of sub levels : one need to implement a recursive function here, and that's the purpose of the select_group field I proposed to integrate in BACKPACK CRUD core for future integrations.
the code for this new field is hosted here on github and for the moment it only deals with single select but this is easily translatable to select2 and select multiples. what do you think ?
Other things to watch, features we'd love
- filter persistence : not there yet ? almost, discussions going on and modifications available on github courtesy of OWEN from Melbourne
- master and details : nova has that possibility of editing sub table rows within the parent row, we call that nested relationship