【问题标题】:Octobercms Possible to update multiple Models in one Controller?Octobercms 可以在一个控制器中更新多个模型吗?
【发布时间】:2018-07-05 13:54:21
【问题描述】:
正如标题所示,是否可以在一个控制器中更新多个模型?我正在使用 Builder Plugin 来处理事情。正如我所见,当我创建控制器时,我们只能选择一个“基本模型”。我们该怎么做?
也是一个附带问题。我可以看到您可以在表单中使用一些选项卡,但我从来没有使用过它们。当我考虑更新多个模型时,我一直在使用选项卡,认为它们可能会用于此目的。
【问题讨论】:
标签:
octobercms
octobercms-plugins
octobercms-backend
【解决方案1】:
其实Builder只是为了kick-starting your plugin或者simpler plugin development,
如果你需要some complex kind of stuff,那么你需要develop/edit files your self,因为builder不能这样做(现在)。
您可以为多个模型保留多个控制器,personally i would say that will be the best practice
不同的场景:
但是但是如果你想edit other model's data from same controller 并且他们有relation to current model 你是currently editing 那么我想我们可以使用relation-manager 将它们显示为relational-field 显示list of related model's records,点击list-item,你会得到modal和you can edit them there。
另一个不同的场景:
如果不是这样,您需要 develop your own controller 您需要 render 您的 forms 和 save 其数据手动。 (因为我们需要定制解决方案)。
要开始定制并构建您的解决方案,此教程将对您有很大帮助。
MVC 在 10 月 CMS 中的工作原理:http://octobercms.com/support/article/ob-19
手动渲染列表和表单:http://octobercms.com/support/article/ob-20
实现嵌套关系: http://octobercms.com/support/article/ob-21
看完本教程you can develop your own controller which can havemultiple formsandlistsand you can将数据保存在单个控制器中`。
信息说明(附带问题的答案):
它们是 just tabs 普通标签,如果您有 model with lot of fields,则可以在 because 那里分开它们分类明智。
例如:
客户模型
- 个人信息可以放在顶层
- 居住地址和公司地址可以进入地址标签
- 联系方式可以在联系方式标签中查看
- 社交详情可以进入社交标签等。