By accessing the website and accepting the Cookie Policy, you agree to use the cookies provided by the Site in accordance with to analyze traffic, remember your preferences, and optimize your experience.
October CMS - 快速入门 12 Repeater字段
2018-10-24 13:04:21    219    0    0
emengweb

Repeater字段是采取Json数据存储多条数据的字段。

【Builder】——【Database】——【raiseinfo_movies_】
为表添加一个新的列:actors

【Models】——【Movie】——【Forms】

分别添加演员姓名和年龄

编辑视频信息:增加演员信息

提示错误

编辑:pluginsraiseinfomoviesmodelsMovie.php

protected $jsonable = ['actors'];

再说保存则错误消失。这样演员信息就被保存到了数据库的actors字段中,以Json格式存储。
查看数据库即可印证上述的结论。

Repeater数据存储到数据中后,如何在前段显示这些数据呢
themesraiseinfopagesmovie-single.htm

<h3>演员</h3>
{% for actor in record.actors %}
    {{ actor.actor_name }}
{% endfor %}

这样就显示了视频的演员信息了,但是,这不是最佳的存储演员信息的方法,我们将到后面使用数据库表的方式存储演员的信息。这里通过这个例子只是说明repeater这种字段的用法。

上一篇: October CMS - 快速入门 13 建立自定义Form Widgets

下一篇: beanstalkd - 基于内存的高性能任务队列系统

219 人读过
文档导航