Below you see a study of a form window which shows data for the database table
shop [section “1” in the screenshot] and below – in the same form window – the hasMany entries from the database table
shop_addresses [section “2”].
What does the below screenshot mean:
There is a shop which has branches over the world and they are maintained in this form.
I am not asking for the database model, I am just asking if somebody could provide me a link to an example where something similar is solved for CakePHP 4.x as this is a very common situation in data handling.
In the section “2” it must be possible to “add/edit/delete” entries for the
shop_addresses table. This means when I create a new row for shop and add then 3 entries for branches and click “Save Shop Name” one row is saved into
shop table and 3 rows are inserted into the
In the existing documentation I don’t find really anything regarding this. I am not saying it’s missing, I just cannot find it.
I really hope you can provide me some examples so I start to understand how to implement it in CakePHP 4.1
The pattern of pages and behaviors you are looking for are what you will see if you bake everything for your models (and if the models follow cake naming conventions).
This Quick-Start page has a pattern like the one you want in the relationship of Users to Articles. Perhaps it will get you rolling.
This is ufortunately exactly what I am not looking for. I follow all cake naming conventions and check them also with this site: http://inflector.cakephp.org/
When I bake the templates I get exactly 1:1 view and not the combined edit form as in my screenshot.
Is there an example how to start regarding such combined edit form or is CakePHP the wrong framework for this and I have to do all by myself? Please check my screenshot how I want to implement a common father <-> son relationship and enter easily lot of son rows…
The standard that Cake uses for this is that the view page for your shop name will give a list of all related records, with links to edit them one at a time or add a new one. What you’re looking for is absolutely something that can be implemented in Cake, and you can also freely change the bake templates so that they generate this sort of a view for you. If you want an example, I can point you to my open-source project (not as a shining example of how it should be done, I’m well aware that there’s lots of technical debt in there, but at least it’s something to look at). The Facilities / Fields, Leagues / Divisions, and Events / Prices relations do just the sort of thing you’re talking about.
I think, we are now very close. I checked your page and for example the " 2020 Summer Monday Night Lights Ultimate" has 8 teams which are listed more or less how I want to have it and your application offers in this case much more possibilities for each row than I want to have.
So, CakePHP doesn’t offer anything from the scratch for this? I have to do all the logic on my own?
But, however, I don’t believe there doesn’t exist anything yet for CakePHP to simplify it. Such a type of edit form is very common and already dBase supported it 30 years ago.
Nothing out of the box that I’m aware of. I’ve heard AdminLTE mentioned, but I don’t know whether it includes anything like this or is just a JS and/or CSS framework to build this sort of thing with. I’d hazard a guess that your multi-record edit is not included by default in Cake, because the large majority of records are more complicated than it permits for; it really only accommodates records with maybe up to three fields in them. I like abstracting common functionality as much as the next guy (maybe even more…), but I’ve not found enough commonality to warrant trying this in my application, despite having three completed examples of how it works.
I am using AdminLTE but there is nothing for this purpose. Somehow I don’t want to believe it that nothing exists in the 21st century.
You could always write a plugin and contribute it.
Isn’t this just a standard ‘view’ page that is showing a related record ‘index’ page? It wouldn’t be hard to move things around slightly so you could do this with an element that had the baked index template in it.
That would get a start with minimal effort.
I made a 'template for cakephp 2.x that when tables have 1:n relationship in the view of the first I let users to add an item of the related, and in add (and edit) of second to search and add an item of the first. So the tables are linked and I have a ‘solid’ base to start. Same thing with n:m.
Now I’d like to do the same for 4.x and I hope to find already built…
(Sorry, hadn´t seen, that the question is from last years august)
Not sure if it´s what you are looking for.
In one of my projects Users can change their userprofile and additional data.
Its just a simple page and behind each “TAB” is a separate form to change additional data.
Can be tested on alltime.recipes (but it is in german and you have to register)