marshmallow/live-update

Edit your Nova resources from the index page.

Maintainers

Package info

github.com/marshmallow-packages/live-update

Language:Vue

pkg:composer/marshmallow/live-update

Statistics

Installs: 40 251

Dependents: 1

Suggesters: 0

Stars: 3

Open Issues: 0

v2.6.0 2025-03-11 19:19 UTC

README

alt text

Laravel Nova Live Update

Latest Version on Packagist Total Downloads Issues License

Edit your Nova resources from the index page. This package adds a TextLiveUpdate field that is editable inline on the index view, so you can update a value without opening the resource's edit screen.

Requirements

  • PHP ^8.1
  • Laravel Nova ^5.0

Installation

Install the package via Composer:

composer require marshmallow/live-update

The package registers its service provider and assets automatically via Laravel's package auto-discovery, so there is nothing else to set up.

Usage

Use the TextLiveUpdate field in a Nova resource exactly like a regular Text field. It becomes editable directly on the index view:

use Marshmallow\LiveUpdate\TextLiveUpdate;

public function fields(NovaRequest $request)
{
    return [
        TextLiveUpdate::make('Name'),
    ];
}

When the value is changed inline, it is validated against the resource's update rules for that attribute before being saved.

Field types

Pass a type to control how the inline input behaves. Using date renders a date picker that saves on change and formats the value as Y-m-d:

TextLiveUpdate::make('Published At', 'published_at')->type('date');

Copyable

Render a button to copy the field's value to the clipboard:

TextLiveUpdate::make('Reference')->copyable();

Copy to another field

Copy the field's value into another field on the same form, with an optional tooltip:

TextLiveUpdate::make('Slug')->copyableTo('seo_slug', 'Copy to SEO slug');

Use as a placeholder

Render the field's value as a placeholder rather than an editable value:

TextLiveUpdate::make('Name')->asPlaceholder();

Listen to another field

Recompute this field's value when another field changes. The callback receives the changed value, the attribute, the model, and the request, and returns the new value:

TextLiveUpdate::make('Full Name')
    ->listen('first_name', 'change', function ($value, $attribute, $model, $request) {
        return trim($value . ' ' . $model->last_name);
    });

Copyable with a server-side action

Run a server-side action and copy its returned value. The action class must implement Marshmallow\LiveUpdate\CopyableActionInterface:

use Illuminate\Database\Eloquent\Model;
use Marshmallow\LiveUpdate\CopyableActionInterface;

class GenerateReference implements CopyableActionInterface
{
    public function execute(Model $model): ?string
    {
        return 'REF-' . $model->getKey();
    }
}

Then wire it up on the field. The optional when callback decides whether the action button is shown:

TextLiveUpdate::make('Reference')
    ->copyableWithAction(
        action: GenerateReference::class,
        icon: 'clipboard',
        target_field_label: 'Reference',
        tooltip: 'Generate a reference',
        when: fn () => true,
    );

Security

If you discover any security related issues, please email stef@marshmallow.dev instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the License File for more information.