wdelfuego/nova-wizard
最新稳定版本:v1.1
Composer 安装命令:
composer require wdelfuego/nova-wizard
包简介
A tool to create wizards in Nova 4.
README 文档
README
Allows you to construct multi-step wizard forms, supports all native and custom Fields in your Laravel Nova 4 application.
Package is abandoned
As of 2025, I have moved my development efforts to Filament and am no longer using or working on this package.
You are free to make and distribute modified versions of this package publicly as long as you distribute it for free, as a stand-alone package and under the same dual licensing model.
License summary
Anyone can use and modify this package in any way they want, including commercially, as long as the commercial use is a) creating implemented wizards and/or b) using the implemented wizards.
Basically, the only condition is that you can't sublicense the package or embed it in a framework unless you do so under the AGPLv3 license (which is incompatible with the Nova framework). More details below.
Installation
-
Add the package to your project;
composer require wdelfuego/nova-wizard
-
Publish the config file;
php artisan vendor:publish --provider="Wdelfuego\NovaWizard\ToolServiceProvider" --tag="config"
-
Update the config file (in
config/nova-wizard.php);The config file allows you to specify as many wizards as you want, each under their own key.
- Update the class name to whatever class name you want to use for this wizard (we will create the class later)
- Update the uri under which the wizard will be available to your end users
- Optionally, update the window title for this wizard
Here's an example minimal config for an
AddUserWizard:use App\Nova\Wizards\AddUserWizard; return [ 'add-user' => [ 'class' => AddUserWizard::class, 'uri' => 'wizard/add-user', 'windowTitle' => 'Add user' ] ];
The key used for each entry in the config file is the 'wizard key' (here:
add-user) and will be required to add the wizard views to yourNovaServiceProvider. -
Update your
NovaServiceProvider;-
Add the following statement to the top of the file:
use Wdelfuego\NovaWizard\NovaWizard; -
Add the wizard tool to the array returned by the
tools()method, supplying the wizard key to its constructor:public function tools() { return [ new NovaWizard('add-user') ]; }
-
If you manually specify your application menu in the
boot()method, add aMenuSectionorMenuItemthat links to this wizard.Specify the wizard key so the correct URL can be generated, like this:
MenuItem::link('Add a user', NovaWizard::pathToWizard('add-user'))
-
-
Finally, implement the wizard;
- Create the class file for your wizard. It can go wherever you want, but
/app/Nova/Wizardsis a good default location if you have no preference. - Make sure you correctly specify that class for the wizard in
config/nova-wizard.php - Implement the class to extend
Wdelfuego\NovaWizard\AbstractWizard. - You only need to implement the following three methods:
-
wizardViewData() : arrayto define the steps and fields in your wizard, like this:use Laravel\Nova\Fields; public function wizardViewData() : array { return [ 'steps' => [ [ 'title' => 'Step 1/2', 'fields' => [ Fields\Text::make(__('Username'), 'username'), Fields\Text::make(__('Text field'), 'myText'), Fields\Textarea::make(__('Longer text'), 'myLongerText') ->help("You can use Help texts on Nova fields like you're used to"), Fields\Number::make(__('Some number'), 'myNumber') ->rules('required') ->withMeta(['value' => 60]) ->min(1) ->step(1), ], ], [ 'title' => 'Step 2/2', 'fields' => [ Fields\Text::make(__('Text field 2'), 'myText2'), Fields\Textarea::make(__('Longer text 2'), 'myLongerText2') ->help("You can use Help texts on Nova fields like you're used to"), Fields\Number::make(__('Some number 2'), 'myNumber2') ->rules('required') ->withMeta(['value' => 60]) ->min(1) ->step(1), ], ], ], ]; }
-
onSubmit($formData, &$context) : boolto specify what to do when valid wizard data is submitted, like this:public function onSubmit($formData, &$context) : bool { // // When this method gets called, a valid and complete wizard was submitted. // // $formData is an array that contains the data submitted by the user. // // $context is an empty array that you can store arbitrary info in; // it will be passed to the next method so you can use it // to display specific context info to the user on success. // Parse submitted wizard data somehow $user = User::create(['name' => $formData['username']]); $context['newUserId'] = $user->id; // Return true at the end of this method to indicate success return true; // Or return false if the data can not be parsed successfully; // the user will then stay in the form view and have a chance // to revise the data before resubmitting. }
-
successViewData($context) : arrayto specify what message to show to the user whenonSubmitreturns true, like this:public function successViewData($context) : array { return [ 'message' => 'Successfully created user with id: ' .$context['newUserId'] ]; }
-
- Create the class file for your wizard. It can go wherever you want, but
Adding more wizards
Repeat step 3 to 5 from the Installation steps above for every wizard you want to add to your Laravel Nova app.
Advanced usage
Using query parameters
As of version 1.1, thanks to a contribution by @olliescase, you can pass query parameters to your wizard URL, that will then be available within the wizard definition so you can customize your wizard or pre-fill certain fields based on the query parameter values.
For example, if you want to use a wizard to do something in the context of a specific Nova resource instance, you could create a Nova Action that returns a parametrized URL:
return $this->redirect('/' . NovaWizard::pathToWizard('my-wizard') . "?parentId={$resource->id}");
Then in the wizard definition you can get the specified parameter value like this:
$this->request->get('parentId')
Or, if you want to use the same wizard definition for two slightly different forms, you could add it to the application menu twice, but differentiate using a query parameter.
You can then get the value of that query parameter in the wizard definition using $this->request->get('paramName') so you can customize the wizard fields and how submissions are processed depending on the context.
Support & Documentation
For any problems or doubts you might run into, please open an issue on GitHub.
License
Copyright © 2023 • Willem Vervuurt, Studio Delfuego, wdelfuego
This entire copyright and license notice must be included with any copy, back-up, fork or otherwise modified version of this package.
You can use this package under one of the follwing two licenses:
-
GNU AGPLv3 for GPLv3-or-newer compatible open source projects. Note that this license is not compatible with usage in Nova, so this package can't be used under this license until a version exists that can be included in Laravel/Vue3 projects without depending on Nova. You can find the full terms of this license in LICENSE-agpl-3.0.txt in this repository and can also find a copy on https://www.gnu.org/licenses/.
-
A perpetual, non-revocable and 100% free (as in beer) do-what-you-want license that allows both non-commercial and commercial use, under the following 6 conditions:
-
You can use this package to implement and/or use as many wizards in as many applications on as many servers with as many users as you want and charge for that what you want, as long as you and/or your organization are either a) the developer(s) responsible for implementing the wizard(s), or b) the end user(s) of the implemented wizard(s), or c) both.
-
Sublicensing, relicensing, reselling or charging for the redistribution of this package (or a modified version of it) to other developers for them to implement wizard views with is not allowed under this license.
-
You are free to make any modifications you want and are not required to make your modifications public or announce them.
-
You are free to make and distribute modified versions of this package publicly as long as you distribute it for free, as a stand-alone package and under the same dual licensing model.
-
Embedding this package (or a modified version of it) in free or paid-for software libraries or frameworks that are available to developers not within your organization is expressly not allowed under this license. If the software library or framework is GPLv3-or-newer compatible, you are free to do so under the GNU AGPLv3 license.
-
The following 2 disclaimers apply:
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
-
wdelfuego/nova-wizard 适用场景与选型建议
wdelfuego/nova-wizard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.5k 次下载、GitHub Stars 达 14, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「wizard」 「nova」 「laravel」 「multistep」 「multi step」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wdelfuego/nova-wizard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wdelfuego/nova-wizard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wdelfuego/nova-wizard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
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
A Laravel Nova package for publishable fields
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.
统计信息
- 总下载量: 20.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 未知
