zetrider/nova-inputs-field
Composer 安装命令:
composer require zetrider/nova-inputs-field
包简介
A Laravel Nova field.
README 文档
README
Multiple fields based on json for Laravel Nova
- Creating multiple fields based on json
- Custom attributes available
- In the arsenal: Input, Select, Checkbox, Radio
Requirements
php: >=7.1laravel/nova: ^3.0
Screenshots
Installation
Install via Composer:
composer require zetrider/nova-inputs-field
Usage
Database
A field in the database should be based on type text.
For example:
$table->text('fields')->nullable(); // Or $table->longText('fields')->nullable(); // Or $table->json('fields')->nullable();
The field stores data in json format.
For example:
[{"exampleTest":"Hello","exampleColor":"#005a9e","exampleDate":"2021-10-28","exampleSelect":"value1","exampleMultiple":["value2","value3"],"exampleCheckbox":["value1","value2"],"exampleRadio":"value3"}]
Data:
- Key: (string) field key
- Value: (array | string ) - depends on field type and the attribute 'multiple'. Checkbox is always an array.
Model
Your model should cast field:
/** * The attributes that should be cast. * * @var array */ protected $casts = [ 'fields' => 'array', ];
Nova resource
The NovaInputsField works like a standard Nova field.
You can use the following methods:
input(string $key, array $attributes)select(string $key, array $attributes, array $options)checkbox(string $key, array $attributes, array $options)radio(string $key, array $attributes, array $options)
$key - used as a key in json
$attributes - any html attributes supported by the field. The placeholder attribute for checkbox and radio fields is used as a title.
$options - options for the field. The array key is value for the option. The array value is the option name.
For example:
use ZetRider\NovaInputsField\NovaInputsField; public function fields(Request $request) { return [ NovaInputsField::make('Some field', 'fields') // Simple text field ->input('exampleTest', ['type' => 'text', 'placeholder' => 'Type here...']) // Color field ->input('exampleColor', ['type' => 'color']) // Date field ->input('exampleDate', ['type' => 'date', 'min' => now()->format('Y-m-d')]) // Simple select ->select('exampleSelect', ['placeholder' => 'Select option...'], [ 'value1' => 'Option1', 'value2' => 'Option2', 'value3' => 'Option3' ]) // Multiple select ->select('exampleMultiple', ['placeholder' => 'Select option...', 'multiple' => 'multiple', 'style' => 'height: 100px;'], [ 'value1' => 'Option1', 'value2' => 'Option2', 'value3' => 'Option3' ]) // Checkbox ->checkbox('exampleCheckbox', ['placeholder' => 'Choice option'], [ 'value1' => 'Check1', 'value2' => 'Check2', 'value3' => 'Check3' ]) // Radio ->radio('exampleRadio', ['placeholder' => 'Some title'], [ 'value1' => 'Radio1', 'value2' => 'Radio2', 'value3' => 'Radio3' ]), ]; }
or
NovaInputsField::make('Prices', 'prices') ->select('type', [], ['base' => 'Base', 'sale' => 'Sale']) ->input('price', ['type' => 'nubmer', 'min' => '1', 'step' => '0.01']),
License
This project is open-sourced software licensed under the MIT license.
zetrider/nova-inputs-field 适用场景与选型建议
zetrider/nova-inputs-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 「field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zetrider/nova-inputs-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zetrider/nova-inputs-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zetrider/nova-inputs-field 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
ConfirmationField is a form field for Atk14 applications. It's like the BooleanField (checkbox) but the ConfirmationField must be ticked.
Field for number with restricted count of digits and decimal places
A simple state dropdown field for SilverStripe forms
A Laravel Nova package for publishable fields
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-28



