# |
Sep 21st 2019, 08:36 |
jotpe |
Is there something like a table prefix? Since I have a lots of models I want to group them to the corresponding plugin. |
# |
Sep 21st 2019, 08:25 |
adam282 |
You’re very welcome |
# |
Sep 21st 2019, 08:24 |
jotpe |
This was lots of help :slightly_smiling_face: |
# |
Sep 21st 2019, 08:24 |
jotpe |
Okay, thanks so much :slightly_smiling_face: |
# |
Sep 21st 2019, 08:23 |
adam282 |
Well, I am out of suggestions then. Sorry bud |
# |
Sep 21st 2019, 08:23 |
adam282 |
Oh, I see. |
# |
Sep 21st 2019, 08:22 |
jotpe |
I guess it's a bit of a requirement to readd them. I can't expose a list of authors, since this will be publicly available. Also people should have different organizations, not just one. Also the db data is truncated once a year. |
# |
Sep 21st 2019, 08:20 |
adam282 |
On the add talk page, provide a drop down of the current people (you can have three different lists if need be) and next to it put a plus button. Let the user choose the person from the list and click the button to actually add that user to the talk (maybe by way of AJAX?). Then, put another button that opens a modal window to add someone not already in the database. |
# |
Sep 21st 2019, 08:19 |
jotpe |
comments will be users, so in this case saving the Authors didn't work |
# |
Sep 21st 2019, 08:19 |
adam282 |
That’s not really a good idea. It will make the database grow and be unorganized and have multiple duplicates. There’s a much better way to do this and that is with associations. |
# |
Sep 21st 2019, 08:19 |
jotpe |
https://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities |
# |
Sep 21st 2019, 08:19 |
jotpe |
My request data looks something like this |
# |
Sep 21st 2019, 08:19 |
jotpe |
So i just readd them |
# |
Sep 21st 2019, 08:19 |
jotpe |
Yes, people can have different organization affiliations. |
# |
Sep 21st 2019, 08:18 |
adam282 |
Okay, but what if you have a new talk and a person already exists in the database table? You’re going to add them again? |
# |
Sep 21st 2019, 08:18 |
jotpe |
yes |
# |
Sep 21st 2019, 08:18 |
adam282 |
Like first name, last name, etc? |
# |
Sep 21st 2019, 08:18 |
jotpe |
yes |
# |
Sep 21st 2019, 08:17 |
adam282 |
Okay, so there are fields? |
# |
Sep 21st 2019, 08:17 |
jotpe |
The author is added in that form, not from a list. To add a author no new view is rendered. It's just the same form. |
# |
Sep 21st 2019, 08:16 |
adam282 |
No problem. I am learning CakePHP 3.x so I feel your pain. |
# |
Sep 21st 2019, 08:15 |
jotpe |
Thanks for your help! ;) I'm just learning |
# |
Sep 21st 2019, 08:15 |
adam282 |
Sorry if I am not being of much help. |
# |
Sep 21st 2019, 08:15 |
adam282 |
So either use a button to add a new person or a drop down with an auto select or something. |
# |
Sep 21st 2019, 08:14 |
adam282 |
Okay, so that’s easy. |
# |
Sep 21st 2019, 08:14 |
adam282 |
When submitted, provided the data is formatted properly and the associations are set up in the model, it should just work. |
# |
Sep 21st 2019, 08:14 |
jotpe |
There's on form to add a talk, within this form you can add Authors, Speakers, ... |
# |
Sep 21st 2019, 08:14 |
adam282 |
So, in one of my apps I have an option for a subscription to be part of multiple distribution lists. To select distribution lists, there’s a multiple select box: ``` <?php echo $this->Form->input('DistributionList', array('type' => 'select', 'empty' => false, 'options' => $lists, 'class' => 'form-control selectpicker', 'id' => 'distribution_list', 'multiple' => true, 'size' => '10')); ?> ``` |
# |
Sep 21st 2019, 08:13 |
adam282 |
Hm, I don’t quite understand. |
# |
Sep 21st 2019, 08:13 |
jotpe |
I add a talk and from this form the user can add authors |
# |
Sep 21st 2019, 08:12 |
adam282 |
Hm, what do you mean? How’s the interface designed? Are you going to a talk and adding people from there or are you going to people and adding talks? I mean, either way, it shouldn’t be that difficult. |
# |
Sep 21st 2019, 08:11 |
jotpe |
Yes, I ended up having some model associations like this. But When I want to add a talk by form it gets messy. Can't just add $requestdata = ['talk.title' ='XYZ', 'authors => ['first_name' => 'Test', ...] |
# |
Sep 21st 2019, 08:09 |
adam282 |
And this is only if `people` can belong to more than one `talk`. If not, you can simply this by removing `talks_peoples` and adding a `talk_id` to the `peoples` table. |
# |
Sep 21st 2019, 08:08 |
adam282 |
Disclaimer: I have done this in CakePHP 2.x but not 3.x so there might be some differences. |
# |
Sep 21st 2019, 08:08 |
adam282 |
Then, `talks_peoples` (not sure those are named according to conventions so verify them) would contain the `talk_id` and the `people_id` and then the `people` would be tied back to a role via their `people_role_id` which comes from `people_roles` |
# |
Sep 21st 2019, 08:07 |
adam282 |
Should be something like that |
# |
Sep 21st 2019, 08:07 |
slackebot |
`people_roles` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(32) DEFAULT NULL, `description` longtext DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ``` |
# |
Sep 21st 2019, 08:07 |
slackebot |
DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `peoples` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `people_role_id` int(11) unsigned NOT NULL DEFAULT '1', `first_name` varchar(32) DEFAULT NULL, `last_name` varchar(32) DEFAULT NULL, `organization` varchar(96) DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE |
# |
Sep 21st 2019, 08:07 |
adam282 |
``` CREATE TABLE `talks` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `call_for_paper_id` int(11) unsigned NOT NULL DEFAULT '1', `category_id` int(11) unsigned NOT NULL DEFAULT '1', `title` varchar(255) DEFAULT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `talks_peoples` ( `people_id` int(11) DEFAULT NULL, `talk_id` int(11) |
# |
Sep 21st 2019, 08:05 |
jotpe |
I tried with a person Model and add a Role to that person. But I can't use save it from the form then. |
# |
Sep 21st 2019, 08:03 |
adam282 |
Hm, shouldn’t be that difficult. |