One-to-many nested editors
One-to-many nested editors
Hi everyone,
Maybe I missed something, but I can't find a way to do it.
Here are more details on what I'm trying to do:
I have two tables:
- Table "items"
- item_id
- item_name
- ...
- Table "subitems":
- subitem_id
- item_id
- subitem_name
...
I want to be able to perform CRUD operations on my subitems directly from the "items" editor.
My first idea was to use a nested editor like this: https://editor.datatables.net/examples/datatables/nested (or multiple version).
However, that isn't the solution because the nested editor lists all the "subitems", and the user needs to select them.
I only want to be able to CRUD "subitems" linked to the current "item" through the "subitems.item_id".
Is there a way to do that with a nested editor?
If not, how could I do it?
Thanks, Renaud
This question has accepted answers - jump to:
Answers
Hi Renaud,
The correct approach will depend upon the exact relationship between the
itemsandsubitemstable. Can there be multiplesubitemsentries assigned to a singleitemsentry for example?If so, then have a look at this parent child editing example which I think will match what you need.
Allan
Hi Allan,
Thanks for your answer.
That look very interresting
Just one question, there is no "server script" in the example, do you have an exemple of it ?
Renaud
Sorry I didn't answer your question, yes, it will be multiple subitems assigned to a single Items.
The controllers used for that demo (and the other examples) are available in the PHP download package. I've put them in below as well:
sites.php:
users.php:
As you'll see the only departure from a normal Editor server-side file is the
wherecondition in users.php and the check there to make sure that something was submitted.Allan
Hi Allan,
Thanks that perfect
Renaud
You are most welcome
Arrrgg, I speak too fast.
Your solution is still perfect
I got an error when I click on the child button :
Are you aware of a bug in button ?
Renaud
Here the html, javascript and CSS code :
I'm sure the issue came from me as your example is working, but I'm struggling to find it !
In your
#promptsDatatable config it looks like the buttons are using the wrong Editor instance ofeditor_main. I think it should be this:Kevin
I believe the problem is with the buttons config for the
#promptsDatatable. They are referencingeditor_,mainbut I believe they should referenceeditor_prompts. Like this:Kevin
Hi thorngen,
Thanks for your feedback.
Unfortunatly, this one are correct, the #prompts Datatable has to be editor_main.
The editor_main is working correctly.
It's the nested editor (editor_prompts) who create the error.
I just saw an error in the button (thanks to you) in the nested editor, here the correct code :
But I still got the same javascript error...
I found the bug !!!!
I define editor_prompts after editor_main !
Thanks for your help
Nice one - thanks for posting back and letting us know it is resolved
Allan
Hi Allan,
Is it possible to edit a post ?
In my post with the code (the first one), I posted the full URL of the tinyMCE javascript load (line 43) with a key, I want to remove it
Renaud