94 lines
2.1 KiB
Markdown
94 lines
2.1 KiB
Markdown
# Nova Form Card
|
|
|
|
Submit-capable Laravel Nova 5 cards powered by standard Nova fields.
|
|
|
|
`nova-form-card` gives Nova cards an Action-like flow: define fields, validate input, submit to a card endpoint, run `handle()`, and return a structured response.
|
|
|
|

|
|
|
|
## Why
|
|
|
|
Nova cards are great for dashboards, but they are usually display-only. This package lets you build reusable form cards without creating a Nova resource page or a custom tool.
|
|
|
|
## Features
|
|
|
|
- Use native Nova fields inside a card
|
|
- Submit data to a package route
|
|
- Validate with Nova field `rules()` / `creationRules()`
|
|
- Receive values through `FormFields`
|
|
- Show validation errors beside fields
|
|
- Support `dependsOn()`, uploads, loading state, custom submit text, and authorization
|
|
- Return success, error, redirect, or refresh responses
|
|
- Render display-only Nova fields such as `Badge`, `Heading`, `Stack`, `Status`, and `Sparkline`
|
|
|
|
## Requirements
|
|
|
|
- PHP `^8.2`
|
|
- Laravel `^11|^12|^13`
|
|
- Laravel Nova `^5`
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
composer require meghdadfadaee/nova-form-card
|
|
```
|
|
|
|
Laravel auto-discovers the service provider.
|
|
|
|
Optional publishes:
|
|
|
|
```bash
|
|
php artisan vendor:publish --tag=nova-form-card-config
|
|
php artisan vendor:publish --tag=nova-form-card-translations
|
|
```
|
|
|
|
## Quick Look
|
|
|
|
```php
|
|
class InviteUserCard extends FormCard
|
|
{
|
|
public function fields(NovaRequest $request): array
|
|
{
|
|
return [
|
|
Text::make(__('Email'))->rules('required', 'email'),
|
|
];
|
|
}
|
|
|
|
public function handle(FormFields $fields, NovaRequest $request): mixed
|
|
{
|
|
return static::message(__('Invitation sent.'));
|
|
}
|
|
}
|
|
```
|
|
|
|
Register it anywhere Nova accepts cards.
|
|
|
|
```php
|
|
public function cards(NovaRequest $request): array
|
|
{
|
|
return [
|
|
new InviteUserCard(),
|
|
];
|
|
}
|
|
```
|
|
|
|
## Documentation
|
|
|
|
Read the full documentation in [docs/documentation.md](docs/documentation.md).
|
|
|
|
Useful files:
|
|
|
|
- [Minimal card example](examples/InviteUserCard.php)
|
|
- [Full demo card](examples/NovaFormCardDemo.php)
|
|
|
|
## Testing
|
|
|
|
```bash
|
|
composer install
|
|
vendor/bin/pest
|
|
```
|
|
|
|
## License
|
|
|
|
Nova Form Card is open-sourced software licensed under the [MIT license](LICENSE.md).
|