marshmallow / nova-fields-help
一个 Laravel Nova 帮助字段。
v2.2.0
2024-03-12 11:42 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
- laravel/nova: ^4.0
- dev-master
- v2.2.0
- v2.1.0
- v2.0.0
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/vue/compiler-sfc-3.2.47
- dev-dependabot/npm_and_yarn/loader-utils-1.4.2
- dev-dependabot/npm_and_yarn/terser-4.8.1
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dependabot/github_actions/overtrue/phplint-8.2
- dev-dependabot/npm_and_yarn/vue-loader-17.0.1
- dev-dependabot/npm_and_yarn/laravel-mix-6.0.49
- dev-dependabot/npm_and_yarn/cross-env-7.0.3
- dev-nova4
- dev-development
This package is auto-updated.
Last update: 2024-09-12 12:41:34 UTC
README
一个自定义 Nova 字段,允许在表单、详情和索引屏幕中显示自定义帮助信息。
变更日志
请在此处查看变更日志。
安装
在您的 nova 项目中运行此命令
composer require marshmallow/nova-fields-help
然后您可以在资源中使用该字段,如下所示
use Marshmallow\Nova\Fields\Help\Help; public function fields(Request $request) { return [ Help::make('Help title', 'Help message!'), ]; }
选项
Nova 帮助字段有许多如下选项
默认模板
Help::make('title', 'message'); // Default help message Help::success('title', 'message'); Help::info('title', 'message'); Help::warning('title', 'message'); Help::danger('title', 'message'); // There's also a special template for headings Help::header('title', 'subtitle'); // If you prefer you can call the non static type method Help::make('title', 'message')->type('warning');
帮助模板
标题模板
标题和消息都是可选的
Help::make('Only title'); Help::make()->message('Only message');
消息也可以是可调用的
Help::make()->message(function () { return "{$this->name} is awesome!"; });
图标
您可以选择 Steve Schoger 提供的默认 SVG 图标(http://www.zondicons.com/)之一。
Help::make('Title')->icon('help'); // the default one Help::make('Title')->icon('info'); Help::make('Title')->icon('warning'); Help::make('Title')->icon('danger'); // Load a custom one Help::make('Love you') ->message('Yes, I love you!') ->icon('<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10 3.22-.61-.6a5.5 5.5 0 0 0 -7.78 7.77l8.39 8.39 8.39-8.4a5.5 5.5 0 0 0 -7.78-7.77z"/></svg>'); // or show no icon at all Help::make('Sad')->withoutIcon();
渲染 HTML 消息
Help::make('Title', 'Message with <a href="#">link</a>')->displayAsHtml();
从 v0.2 版本开始,displayAsHtml()
方法也适用于字段名称(除非在索引中作为列标题显示)。
在详情屏幕上全宽显示
// Remove annoing padding in detail screen, also the default behaviour for the heading template Help::make('Negative margin')->showFullWidthOnDetail();
带有侧标签
// Show a side label instead of the title on the top Help::make('Look I\'m on the side') ->message('I\'m not...') ->withSideLabel();
可折叠的帮助字段
可以使用流畅方法 collapsible()
将帮助字段设置为可折叠。可折叠的帮助字段默认是折叠的,点击标题可以切换其状态。请注意,可折叠字段必须定义标题和消息,并且不能与侧标签一起使用。
// Collapsible field Help::info('Click here to toggle', 'Lorem ipsum dolor sit amet...') ->collapsible();
在索引中显示帮助信息
/** * By default help messages aren't shown on index, * when enabled they are shown as an hoverable * icon showing a plain (no html) tooltip. */ Help::make('Column title') ->message('Message with <a href="#">link</a>') // The link code will be stripped out on index ->alsoOnIndex(); // Field icons can be shown conditionally on index Help::make()->message(function () { return $this->name?"{$this->name} is awesome!":null; })->onlyOnIndex();
变更日志
有关最近更改的更多信息,请参阅变更日志。
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件stef@marshmallow.dev联系,而不是使用问题跟踪器。
鸣谢
许可
MIT 许可证(MIT)。请参阅许可文件以获取更多信息。