Json Column
A simple package to view and edit your JSON columns.
Author:
Valentin Morice
Documentation
#v3.0 - Filament 4 Support
Now supports Filament 4.x with the new unified schema system!
#Version Compatibility
- v3.x: Filament 4.x, Laravel 11.x, PHP 8.2+
- v2.x: Filament 3.x, Laravel 10.x+, PHP 8.1+ (maintenance branch)
A simple package to view and edit your JSON columns in Filament 4.
#Installation
You can install the package via composer:
composer require valentin-morice/filament-json-column
For Filament 3.x support, use version 2.x:
composer require valentin-morice/filament-json-column:^2.0
#Usage
The filament-json-column plugin works as any other Filament Form Builder classes. Make sure the column on which it is called is cast to JSON or array within your Eloquent model.
use ValentinMorice\FilamentJsonColumn\JsonColumn;
use ValentinMorice\FilamentJsonColumn\JsonInfolist;
use Filament\Schemas\Schema;
public static function form(Schema $schema): Schema
{
return $schema
->schema([
JsonColumn::make('example'),
]);
}
// An infolist component is also available.
public static function infolist(Schema $schema): Schema
{
return $schema
->schema([
JsonInfolist::make('example'),
]);
}
The form component provides you with two tabs: Viewer & Editor. The Viewer tab pretty prints your JSON data, while the Editor tab lets you edit it conveniently.
All the methods provided by the plugin accept closures, injected with standard Filament utilities.
#Personalize the accent color
The tab selector menu uses the slateblue CSS color by default. However, you can choose any other color:
JsonColumn::make('example')->accent(string '#FFFFFF'|Closure); // The input needs to be a valid CSS color
#Display a single tab
If you'd like to use only one of the tabs, without giving your user the possibility to switch to another, use the following methods:
JsonColumn::make('example')->editorOnly(bool|Closure); // Displays only the editor tab
JsonColumn::make('example')->viewerOnly(bool|Closure); // Displays only the viewer tab
#Change the height
JsonColumn::make('example')->editorHeight(int 500|Closure); // Accepts an int, defaults to 300
JsonColumn::make('example')->viewerHeight(int 500|Closure); // Accepts an int, defaults to 300
#Editor modes
Customize the editor modes. Accepted values (and default) are: ['code', 'form', 'text', 'tree', 'view', 'preview']
JsonColumn::make('example')->modes(array|Closure ['code', 'text', 'tree']);
#Validation
Values are validated as proper JSON by default.
#Compatibility
- Filament 4.x (v3.x of this package)
- Filament 3.x (v2.x of this package - see 2.x branch)
- Laravel 11.x
- PHP 8.2+
#Credits
I've taken inspiration from the following plugins: Pretty JSON & JSONeditor.
#License
The MIT License (MIT). Please see License File for more information.
The author
From the same author
Featured Plugins
A selection of plugins curated by the Filament team
Custom Dashboards
Let your users build and share their own dashboards with a drag-and-drop interface. Define your data sources in PHP and let them do the rest.
Filament
Data Lens
Advanced Data Visualization for Laravel Filament - a premium reporting solution enabling custom column creation, sophisticated filtering, and enterprise-grade data insights within admin panels.
Padmission
Custom Fields
Eliminate custom field migrations forever. Let your users create and manage form fields directly in Filament admin panels with 20+ built-in field types, validation, and zero database changes.
Relaticle