Master.Detail Controllers/Forms Resources


#1

I’m building an application that has many hasMany relationships. Ideally, this results in many master-detail forms for data entry with controllers managing the saving of data to two (or more) tables. While I basically know how to build such things, they are a repetitive pain-in-the-neck to build and are error prone. Most frameworks, like Yii2 and Laravel, have plugins to help with master-detail. Unfortunately, I’ve searched in vain trying to find such plugins for CakePHP; I haven’t even been able to find some models for such development. (Note that I’m using “model” here as as a development pattern, not a relationship. I know full well how to build hasMany relationships and the far more common belongsToMany relationships with linking tables.)

Clearly, any application of even the simplest sort, will require many, many, many such forms. It is literally impossible to think of an application that wouldn’t require many such forms. Just think of recipes with ingredients, how to’s with supplies, health logs with medications, purchase orders with items, and on and on. To have to enter the master information and save it in one form and then enter the detail on a separate form using a lookup combo box for the master is ridiculously cumbersome beyond belief.

Surely there must be a plugin for such things or, at the very least, some sort of tutorial/instructions/suggested development model that I’m missing. Can anyone give me any suggestions in this regard?


#2

You’re saying that you’d build a purchasing system whereby new items can be entered and saved into the system from the order page? New medications entered as part of logging that they were given to a patient? That sort of thing?


#3

I think hes looking for a plugin to add/delete dynamically associated (hasMany) itens in the forms

like this:

if the associated itens dont have extra editable data like quantity, price etc i use select2 multi-select option:
https://select2.org/getting-started/basic-usage#multi-select-boxes-pillbox


#4

Precisely, just like in pretty much any real-world application. For instance, in the master table, one might have all the order data (customer id, date of order, shipping method and so on). The purchaser id would be from a customer table. In the child table, one would have, for each record, quantity, item number, unit price, and so on. The order page would have separate rows for each item entered and the ability to add rows as needed for a virtually unlimited number of items. If you order online at all, you’ve seen it every time you’ve ever placed an order. It’s something that’s totally ubiquitous, so commonplace and vitally necessary to every website that’s in any way beyond trivial.


#5

The YouTube video looks like what I’m talking about, although without any verbal explanation it’s pretty hard to tell what’s going on in the video. Yes, I’m talking about multiple fields for each child record. It’s not at all like tagging where you’re simply attaching multiple tags to a master record, another commonplace, also a vitally necessary component of any modern day web application.

I’m completely dumbfounded that these two very different but completely commonplace components cause so much confusion in the CakePHP forum. I was thinking that each of them would almost be built into Cake itself because they are so very commonplace. Failing that, there should be plugins for each them listed at the very top of the plugins page because you simply cannot build a web application that’s beyond trivial without them.