- How do I install creagia/filament-code-field in a Laravel app?
- Install it with Composer by running composer require creagia/filament-code-field. The package supports Laravel package autodiscovery, so no manual service provider registration or config publishing is required. Then add CodeField::make('my_json') inside any Filament form schema, for example in your resource's form() method, and the CodeMirror editor renders automatically.
- Which package version works with Filament 3 and Laravel 10, 11 or 12?
- The README says the latest version requires Filament 3 and Laravel 11, while the 2.x line is documented for Filament 3 on Laravel 10 through 12. Release notes for 3.0.3 also advertise Laravel 10-12 and PHP 8.1-8.4 compatibility, so the README appears to lag the changelog. Read the composer.json constraints in the tag you install instead of trusting either document, and pin an exact constraint like ^3.0 or ^2.0 so your lockfile resolves it. Version 1.x is the only line that supports Filament 2, and adopting it is rarely worth it versus upgrading Filament.
- Which languages can the code field highlight and edit?
- The documented grammars are JSON, which is the default, plus PHP, HTML, XML and JavaScript, with SQL added in 1.0.2. Switch languages with setLanguage(CodeField::PHP) or the fluent helpers such as jsField(). Claims of 100+ languages are not supported by the package, so verify YAML, Blade or other grammars before you commit to them.
- How do I make the code field read-only in a Filament resource?
- Chain ->disabled() on the CodeField instance to display code without allowing edits, which is the lowest-risk way to use the package. Read-only display avoids the main hazard of storing arbitrary code that might later be executed. You still get CodeMirror syntax highlighting and theme matching rather than a plain textarea.
- How do I disable code autocompletion on the field?
- Call ->disableAutocompletion() on the field; completion is enabled by default. This is useful for short configuration snippets or mostly read-only fields where suggestions add noise. It combines with other chainable options such as ->withLineNumbers(), and inherited Filament methods like label(), hint() and helper text still work as usual.
- Does the editor match my Filament admin panel light and dark theme?
- Yes, the CodeMirror instance renders in light or dark mode to match your panel theme, so it stays visually consistent when users toggle appearance. Assets are registered through Filament's standard asset pipeline, so your deploy needs the usual asset build or publish step. There are no queue, cache or storage requirements introduced by the package.
- Can I add validation rules such as required, max or min length to the code field?
- Yes. The field extends Filament's field class, so standard Laravel rules such as required, max and min apply normally. Field-specific min and max length support arrived in version 3.0.2, so pin at least that release if you depend on it. For JSON content, add Laravel's json rule or a custom rule so syntax errors are rejected before saving.
- Is it a performance problem to have several code editors on one page?
- Each CodeField pulls CodeMirror JavaScript and CSS onto the page, and multiple editors compound both asset weight and initialisation cost. One or two editors on a settings screen is fine, but avoid the field in long tables, repeaters or anything rendering many instances. If you already standardise on Monaco or Ace, consolidating on a single editor stack is the better decision.
- Is it safe to let users edit code that the application later executes?
- The package only stores and displays whatever code is entered; escaping and any downstream execution are entirely your responsibility. Executing snippets saved from an admin panel is effectively remote code execution, so never run them without sandboxing, allow-listing or strict review. Keep the field read-only for non-developers and treat the panel as a trusted surface, not an execution layer.
- Is creagia/filament-code-field actively maintained, and what are the alternatives?
- It is maintained by a single agency, Creagia, with a small audience of roughly 57 GitHub stars and no known dependents, so no downstream population will surface regressions before you do. Recent 3.0.x releases are mostly Dependabot bumps to GitHub Actions and dev-only JS dependencies, which signals hygiene rather than roadmap investment. Budget a re-evaluation at every Filament major release, since Filament's form API churns and field packages commonly break there. If you need a heavier editor, Monaco or Ace-based packages are the usual alternatives.