如何在GRAV CMS中编写Controller

时间:2019-09-15 18:04:14

标签: php grav

我创建了一个表单,希望将提交的数据保存在后端

ngOnInit() {
 this.subjectService.createSubjectForm(this, this.subject);
}

我希望这样的代码

createSubjectForm(scope, subject) {
    scope.subjectForm = this.fb.group({
      'path': [[]],
    });
    if (subject.subjectFormatSubjects)
      this.createSectionForm(scope.subjectForm.controls, subject.subjectFormatSubjects.data)
  }
  createSectionForm(formPath, sections) {
    if (!formPath['structure'])
      formPath['structure'] = this.fb.array([]);
    sections.forEach((section) => {
      (<FormArray>formPath['structure'].controls).push(this.fb.group({
        'title': [section.title, Validators.required]
      }));
      const sectionIndex = formPath['structure'].controls.length - 1;
      formPath['structure'].controls[sectionIndex].controls['path'] = this.fb.control([...formPath.path.value, sectionIndex]);
      if (section.subjectFormatSubjects) {
        this.createSectionForm(formPath['structure'].controls[sectionIndex].controls, section.subjectFormatSubjects.data);
      }
    });
  }

但是我在文档中找不到任何有关自定义控制器的教程

我如何实现这个目的?

0 个答案:

没有答案