sandritsch91/yii2-widget-form-wizard
Composer 安装命令:
composer require sandritsch91/yii2-widget-form-wizard
包简介
A Yii2 form-wizard widget for bootstrap 5
README 文档
README
A Yii2 form-wizard widget for bootstrap 5
Features
- Bootstrap 5
- Client side validation, with the option to validate each step separately
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist sandritsch91/yii2-form-wizard
or add
"sandritsch91/yii2-form-wizard": "*"
to the require section of your composer.json
Usage
use sandritsch91\yii2-form-wizard\FormWizard; echo FormWizard::widget([ // required 'model' => $model, // The model to be used in the form 'tabOptions' => [ // These are the options for the Bootstrap Tab widget 'items' => [ [ 'label' => 'Step 1', // The label of the tab, if omitted, a default-label will be used (Step 1, Step 2, ...) 'content' => $this->render('_step1', ['model' => $model]), // Either the content of the tab ], [ 'label' => 'Step 2', 'view' => '/test/_step2', // or a view to be rendered. $model and $form are passed to the view 'params' => ['a' => 1, 'b' => 2] // Pass additional parameters to the view ] ], 'navType' => 'nav-pills' ], // optional 'validateSteps' => [ // Optional, pass the fields to be validated for each step. ['name', 'surname'], [], // Leave array empty if no validation is needed ['email', 'password'] ], 'options' => [], // Wizard-container html options 'formOptions' => [], // Form html options 'buttonOptions' => [ // Button html options 'previous' => [ 'class' => ['btn', 'btn-secondary'], 'data' => [ 'formwizard' => 'previous' // If you change this, make sure the clientOptions match ] ], 'next' => [...], 'finish' => [...] ], 'clientOptions' => [ // Client options for the form wizard, if you need to change them // 'finishSelector' => '...', // 'nextSelector' => '...', // 'previousSelector' => '...', // 'keepPosition' => true // Keep scroll position on step change. // Set to false to disable, or pass a selector if you have a custom scroll container. // Defaults to true. ], 'clientEvents' => [ // Client events for the form wizard // 'onNext' => 'function () {...}', // 'onPrevious' => 'function () {...}', // 'onFinish' => 'function (){...}' ] ]);
Contributing
Contributions are welcome.
If you have any questions, ideas, suggestions or bugs, please open an issue.
Testing
This package uses codeception for testing. To run the tests, run the following commands:
php.exe .\vendor\bin\codecept run for all test suites
Unit tests
run php.exe .\vendor\bin\codecept run Unit in the root directory of this repository.
Functional tests
run php.exe .\vendor\bin\codecept run Functional in the root directory of this repository.
Accpetance tests
To be able to run acceptance tests, a few requirements are needed:
For Windows:\
- install java runtime environment
- install nodejs
- install selenium-standalone:
npm install -g selenium-standalone - start selenium-standalone:
selenium-standalone install && selenium-standalone start - host a yii2 application on a server or locally via
./yii serve- add this plugin as a dependency to your
composer.jsonand update dependencies - site must be reachable over http://formwizard.com/
- add an action
actionTestto theSiteController, as described below - this action must return a view file, as described below
- run
php.exe .\vendor\bin\codecept run Acceptance
- add this plugin as a dependency to your
For Linux:
Never did that before, but I think it is similar to the Windows setup.
The action in the SiteController:
public function actionTest(): string { include __DIR__ . '/../vendor/sandritsch91/yii2-widget-form-wizard/tests/Support/Data/models/User.php'; $model = new User(); if (Yii::$app->request->post() && $model->load(Yii::$app->request->post()) && $model->validate()) { return 'success'; } return $this->render('test', [ 'model' => new User() ]); }
The view returned by the action:
/** @var User $model */ use sandritsch91\yii2\formwizard\FormWizard; use sandritsch91\yii2\formwizard\tests\Support\Data\models\User; $wizard = FormWizard::widget([ 'model' => $model, 'tabOptions' => [ 'options' => [ 'class' => 'mb-3' ], 'items' => [ [ 'label' => 'Step 1', 'view' => '@app/vendor/sandritsch91/yii2-widget-form-wizard/tests/Support/Data/views/site/step1', 'linkOptions' => [ 'id' => 'step1-link',, 'params' => [ 'test' => 'some test variable' ] ] ], [ 'label' => 'Step 2', 'view' => '@app/vendor/sandritsch91/yii2-widget-form-wizard/tests/Support/Data/views/site/step2', 'linkOptions' => [ 'id' => 'step2-link', ] ], [ 'label' => 'Step 3', 'view' => '@app/vendor/sandritsch91/yii2-widget-form-wizard/tests/Support/Data/views/site/step3', 'linkOptions' => [ 'id' => 'step3-link', ] ] ], 'navType' => 'nav-pills' ], 'validateSteps' => [ ['firstname', 'lastname'], ['username', 'password', 'password_validate'], ['email'] ], 'clientOptions' => [ 'keepPosition' => true ] ]); echo \yii\helpers\Html::tag('div', $wizard, [ 'class' => 'col-4' ]);
After the initial installation, you only have to start the selenium-standalone server selenium-standalone start
and run the tests php.exe .\vendor\bin\codecept run Acceptance in the root directory of this repository.
If you do not want to setup an application, just run the unit and functional tests by
running php.exe .\vendor\bin\codecept run Unit,Functional, I can modify and run the acceptance tests for you,
after you opened a pull request.
sandritsch91/yii2-widget-form-wizard 适用场景与选型建议
sandritsch91/yii2-widget-form-wizard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 525 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「bootstrap」 「wizard」 「widget」 「yii2」 「bootstrap5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sandritsch91/yii2-widget-form-wizard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sandritsch91/yii2-widget-form-wizard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sandritsch91/yii2-widget-form-wizard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides methods to create, validate and render HTML forms in PHP.
Site generator / tree model duplicator used to generate mini-website or duplicate tree model
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
A Laravel Filament Forms slug field.
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 525
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-08
