我可以将转发器小部件设置为在表单打开时自动加载吗?
它具有最大项目属性,它可以自动加载到最大项目数
所以用户不需要点击提示按钮
重新更新
这是我的 fields.yaml
fields:
nowarta:
label: 'No. Warta'
oc.commentPosition: ''
span: auto
placeholder: 'format penulisan ''No. 34 Tahun XIX'''
type: text
tanggal:
label: Tanggal
oc.commentPosition: ''
mode: date
format: 'd - F - Y'
span: right
type: datepicker
ignoreTimezone: false
renungan:
label: 'Renungan Mingguan'
oc.commentPosition: ''
span: full
type: section
renungan[judul]:
label: 'Judul Renungan'
oc.commentPosition: ''
span: storm
type: text
cssClass: 'col-sm-6 col-sm-push-0'
renungan[bahanbaca]:
label: 'Bahan Bacaan'
oc.commentPosition: ''
span: storm
type: text
cssClass: col-sm-6
renungan[isi]:
label: Renungan
oc.commentPosition: ''
span: storm
cssClass: 'col-sm-12 col-sm-push-0'
type: richeditor
size: huge
tabs:
fields:
temakebum:
label: 'Kebaktian Umum'
oc.commentPosition: ''
span: full
type: section
tab: 'Kebaktian Umum & Komisi'
temakebum[tema]:
tab: 'Kebaktian Umum & Komisi'
label: Tema
oc.commentPosition: ''
span: storm
cssClass: col-sm-11
type: text
temakebum[bacaan]:
label: 'Bahan Bacaan'
oc.commentPosition: ''
span: storm
cssClass: col-sm-6
type: text
tab: 'Kebaktian Umum & Komisi'
temakebum[pujian]:
label: Pujian
oc.commentPosition: ''
span: storm
cssClass: col-sm-6
type: text
tab: 'Kebaktian Umum & Komisi'
kebum:
label: ''
oc.commentPosition: ''
prompt: 'Tambah Data'
maxItems: '3'
span: full
type: repeater
tab: 'Kebaktian Umum & Komisi'
form:
fields:
jeniskeb:
label: 'Jenis Kebaktian'
oc.commentPosition: ''
span: storm
cssClass: col-sm-4
type: dropdown
options: jenisKeb
khotbah:
label: Pengkhotbah
oc.commentPosition: ''
span: storm
cssClass: col-sm-4
placeholder: ''
type: text
dd($form->fields)
array:6 [▼
"nowarta" => array:5 [▶]
"tanggal" => array:7 [▶]
"renungan" => array:4 [▶]
"renungan[judul]" => array:5 [▶]
"renungan[bahanbaca]" => array:5 [▶]
"renungan[isi]" => array:6 [▶]
]
这就是我在控制器中所做的,如你所愿..
class WartaRutin extends Controller
{
public $implement = ['Backend\Behaviors\ListController','Backend\Behaviors\FormController','Backend\Behaviors\ReorderController' ];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public $reorderConfig = 'config_reorder.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('Mismaiti.MyWarta', 'main-menu-item', 'side-menu-rutin');
}
public function formExtendFieldsBefore($form) {
// we are checking we are creating record or updating
// or even we can use $form->context here but I used $model->id
// if $form->context == 'update'
// if $form->context == 'create'
if(is_null($form->model->id)) {
// create time
$iteration = $form->fields['kebum']['maxItems'];
if(is_numeric($iteration) && $iteration > 0) {
$emptyFields = [];
while($iteration > 0) {
$emptyFields[] = ['jeniskeb' => ''];
$iteration--;
}
$form->model->kebum = $emptyFields;
}
}
}
}
当我尝试执行时它返回一个错误——我已将所有 repeater_data 替换为 kebum
C:\xampp\htdocs\mywarta\plugins\mismaiti\mywarta\controllers\WartaRutin.php 第 30 行的“未定义索引:kebum”
我在这里错过了什么..?