ronnytorresmtz/text-inline is a Laravel package for a laravel nova field..
It currently has 0 GitHub stars and 48 downloads on Packagist (latest version 1.0.12).
Install it with composer require ronnytorresmtz/text-inline.
Discover more Laravel packages by ronnytorresmtz
or browse all Laravel packages to compare alternatives.
Last updated
This package allow you to edit a text field in the index page with one click
composer require ronnytorresmtz/text-inline
use Ronnytorresmtz\TextInline\TextInline;
public function fields()
{
return [
TextInline::make('Name')
->inlineOnIndex(),
];
}
To edit the text field you need to click it on, and base on the saveOn event defined the text field value will be store in the database.
If you press the Esc key the field text will return to a not editable mode or if the text field lost the focus.
This method also accepts a closure with the current request if you want to make it editable dynamically:
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex(function (NovaRequest $request) {
return $request->user()->isAdmin();
}),
];
}
The default trigger to save the value is by pressing the Enter key (keyup.enter). If you wish to use a different event trigger to update the value you can use the saveOn() method that accepts an argument corresponding to a javascript event:
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex()
->saveOn('blur'),
];
}
You can also specify the key event modifier:
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex()
->saveOn('keyup.shift'),
];
}
The credit for this package belongs to PDMFC I just add the clickable functionality to enable the edit mode and add one listener for blur event to enable the readonly mode. Also I eliminate the refreshTable method.
This package was based on the package pdmfc/nova-inline-text