← Back to Plugins
  • "Import Inline" Input - Paste data, validate it, and fill your form!

"Import Inline" Input - Paste data, validate it, and fill your form!

Plugin information

by camya • 8 stars

Form builder Field Admin panel

The ImportInline Input component helps you to paste machine-readable data like JSON or CSV, validate it, and import it into your form fields.

Support

#import-inline-form-paste on Discord

Views

598

License

MIT

Documentation

The ImportInline Input component helps you to paste machine-readable data like JSON or CSV, validate it, and import it into your form fields.

The plugin can automatically import data via the "on paste" event, which makes it a great tool for increasing productivity when editing content. Just click in the input field and paste the data of the clipboard.

You can validate imported data using the standard Laravel Validation Rules. The plugin comes with two handy importers for JSON and CSV, but you can also just write and use your own importer.

Quick jump to the documentation.

Watch the » Demo Video «

You can install the package via composer:

composer require camya/filament-import-inline

Use it in your Filament Resource:

ImportInlineInput::make('Import')
->afterStateUpdated(
function ($state, Closure $set, ImportInlineInput $component): void {
 
$validator = $component->validator();
 
try {
$importedData = Import::jsonString($state);
} catch (\Exception $e) {
$validator->setValidationError($e->getMessage());
}
 
$validatedData = $validator->validate(
data: $importedData,
rules: [
'title' => [
'required',
],
'slug' => [
'required',
],
'content' => [
'required',
],
],
messages: [
'title.required' => 'title is required',
'slug.required' => 'slug is required',
'content.required' => 'content is required',
]
);
 
$set('title', $validatedData['title']);
$set('slug', $validatedData['slug']);
$set('content', $validatedData['content']);
 
$component->statusMessage('Data imported <strong>successful!</strong>');
 
}
)
->dataHelperHtml('Example JSON: {"title":"Lorem","slug":"ipsum","content":"Hello"}')
->dataHelperLink('https://www.camya.com/', 'Help')

Features

Visit the GitHub Repository for all details.