承接 junkins/multi-step-form 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

junkins/multi-step-form

最新稳定版本:3.5.7

Composer 安装命令:

composer require junkins/multi-step-form

包简介

CakePHP MultiStepForm

README 文档

README

Introduction

MultiStepForm is Plugin to help your multi step form.

Requirements

  • CakePHP >= 3.0

Setup

AppFormHelper

<?php namespace App\View\Helper; use MultiStepForm\View\Helper\Traits\MultiStepFormHelperTrait; class AppFormHelper extends FormHelper { use MultiStepFormHelperTrait; // Submit用のボタン名称設定 public $nextLabel = '確認'; public $backLabel = '戻る'; public $nextClass = ''; public $backClass = ''; } 

AppView.php

<?php namespace App\View; use Cake\View\View; class AppView extends View { /** * initialize */ public function initialize() { // AppFormHelperの読み込み設定 $this->loadHelper('Form', [ 'className' => 'AppForm', ]); } } 

Examples

  1. Simple Form
<?php namespace App\Controller; use MultiStepForm\Controller\Traits\MultiStepFormTrait; /** * TopicsController */ class TopicsController extends Controller { use MultiStepFormTrait; /** * initialize */ public function initialize() { parent::initialize(); // 通常のアクションとしてアクセスが必要な場合は whitelist に設定する $this->loadComponent('MultiStepForm.MultiStepForm', [ 'whitelist' => [ 'index', 'view', 'add', 'edit', 'delete' ] ]); } /** * add */ public function add() { $this->MultiStepForm->dispatch(); } /** * add_input */ public function add_input() { $topic = $this->MultiStepForm->getEntity(); $this->set(compact('topic')); $this->render('add_input'); } /** * add_confirm */ public function add_confirm() { $topic = $this->MultiStepForm->getEntity(); $this->set(compact('topic')); $this->render('add_confirm'); } /** * add_finish */ public function add_finish() { $data = $this->MultiStepForm->getData(); $topic = $this->Topics->newEntity($data); if($this->Topics->save($topic)){ $this->Flash->success('Success!'); } else { $this->Flash->error('Error!'); } $this->redirect(['action' => 'index']); } } 
// Submit Button // 次の画面に進むためのボタン表示 // 第一引数は設置する画面名 // 第二引数はその他の設定 // nextlabel:ボタン名 // nextClass:ボタンのクラス <?= $this->Form->next(); ?> <?= $this->Form->next('add_input'); ?> <?= $this->Form->next('add_input', [ 'nextlabel' => '次へ' ]); ?> OR // 次の画面もしくは、前の画面に進むためのボタン表示 // 第一引数は設置する画面名 // 第二引数はその他の設定 // nextlabel:ボタン名 // backlabel:ボタン名 // nextClass:ボタンのクラス // backClass:ボタンのクラス <?= $this->Form->nextOrBack(); ?> <?= $this->Form->nextOrBack('add_input'); ?> <?= $this->Form->nextOrBack('add_input', [ 'nextlabel' => '次へ', 'backlabel' => '戻る', ]); ?> 
  1. Custom Form

Controller

<?php namespace App\Controller; use MultiStepForm\Controller\Traits\MultiStepFormTrait; /** * TopicsController */ class TopicsController extends Controller { use MultiStepFormTrait; /** * initialize */ public function initialize() { parent::initialize(); // 通常のアクションとしてアクセスが必要な場合は whitelist に設定する $this->loadComponent('MultiStepForm.MultiStepForm', [ 'whitelist' => [ 'index', 'view', 'add', 'edit', 'delete' ] ]); } /** * edit */ public function edit($id = null) { // $modelClass以外のTableを使用する場合 $this->MultiStepForm->setTable('Projects'); // デフォルトの設定を全て上書きする場合 $this->MultiStepForm->setConfigMultiStep([ 'edit_first_input' => [ 'id' => $id, 'back' => false, 'next' => 'edit_second_input', 'validate' => 'default', 'multiple' => false, 'associated' => [] ], 'edit_second_input' => [ 'id' => $id, 'back' => 'edit_first_input', 'next' => 'edit_third_input', 'validate' => 'default', 'multiple' => false, 'associated' => [] ], 'edit_third_input' => [ 'id' => $id, 'back' => 'edit_second_input', 'next' => false, 'validate' => 'default', 'multiple' => false, 'associated' => [] ], ]); // デフォルトの設定を一部上書きする場合 $this->MultiStepForm->mergeConfigMultiStep([ 'edit_input' => [ 'id' => $id ] ]); // Hash パス構文で設定を上書きする場合 $this->MultiStepForm->insertConfigMultiStep('edit_second_input.validate', false); $this->MultiStepForm->insertConfigMultiStep('{*}.validate', false); $this->MultiStepForm->dispatch(); } 
  1. Model Less Form
<?php namespace App\Controller; use App\Controller\AppController; use App\Form\ContactsForm; use Cake\Event\Event; use MultiStepForm\Controller\Traits\ModelLessMultiStepFormTrait; /** * ContactsController */ class ContactsController extends AppController { use ModelLessMultiStepFormTrait; /** * initialize * * @return void */ public function initialize() { parent::initialize(); // 通常のアクションとしてアクセスが必要な場合は whitelist に設定する $this->loadComponent('MultiStepForm.ModelLessMultiStepForm', [ 'whitelist' => [ 'index', 'thanks' ] ]); } /** * index * * @return void */ public function index() { $form = new ContactsForm(); $this->ModelLessMultiStepForm->setForm($form); $this->ModelLessMultiStepForm->dispatch(); } /** * index_input * * @return void */ public function index_input() { $form = $this->ModelLessMultiStepForm->getForm(); $this->set(compact('form')); $this->render('index'); } /** * index_confirm * * @return void */ public function index_confirm() { $form = $this->ModelLessMultiStepForm->getForm(); $data = $this->ModelLessMultiStepForm->getData(); $this->set(compact('form', 'data')); $this->render('index_confirm'); } /** * index_finish * * @return void */ public function index_finish() { $data = $this->ModelLessMultiStepForm->getData(); $form = $this->ModelLessMultiStepForm->getForm(); if ($form->execute($data)) { $this->redirect(['action' => 'thanks']); } else { $this->redirect(['action' => 'index']); } } /** * thanks * * @return void */ public function thanks() { } } 

统计信息

  • 总下载量: 38.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固