lekoala / silverstripe-multi-step-form

SilverStripe 的多步骤表单

安装: 8

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

开放性问题: 1

类型:silverstripe-vendormodule

dev-master 2024-04-03 11:31 UTC

This package is auto-updated.

Last update: 2024-09-03 12:16:02 UTC


README

Build Status scrutinizer Code coverage

简介

multiform(https://github.com/silverstripe/silverstripe-multiform)的简单替代品

此模块不需要在后台存储,并提供一种相对更容易的 DX。

工作原理

表单的每个步骤应该具有相同的名称。

  • MyFormStep1
  • MyFormStep2
  • ...

它们都应该扩展基类 MultiStepForm 并实现以下抽象方法

  • buildFields : 返回字段列表
  • getStepTitle : 获取步骤标题
class MyFormStep1 extends MultiStepForm
{
    public static function getStepTitle()
    {
        return 'My Step';
    }

    public function buildFields()
    {
        $fields = new FieldList();
        return $fields;
    }
}

在你的控制器中,你可以这样声明一个表单

private static $allowed_actions = array(
    'MyForm'
);

public function MyForm()
{
    $class = MyFormStep1::classForCurrentStep($this);
    return new $class($this);
}

模板助手

你可以使用以下方法显示步骤

$MyForm.DisplaySteps

这依赖于一些默认样式,这些样式默认添加。你可以禁用样式并使用以下方法编辑自定义类

LeKoala\MultiStepForm\MultiStepForm:
    include_css: true
    class_active: "current bg-primary text-white"
    class_inactive: "link"
    class_completed: "msf-completed bg-primary text-white"
    class_not_completed: "msf-not-completed bg-light text-muted"

待办事项

  • 文档
  • 测试

兼容性

已测试 4.6 版本,但应在任何 ^4.4 项目中工作

维护者

LeKoala - thomas@lekoala.be