diff --git a/resources/views/forms/components/json-input.blade.php b/resources/views/forms/components/json-input.blade.php index eed5139..76158f2 100644 --- a/resources/views/forms/components/json-input.blade.php +++ b/resources/views/forms/components/json-input.blade.php @@ -3,9 +3,6 @@ :field="$field" > - @php - ray($getStatePath()) - @endphp
diff --git a/resources/views/infolists/components/json-entry.blade.php b/resources/views/infolists/components/json-entry.blade.php index 488f87e..ffcd05e 100644 --- a/resources/views/infolists/components/json-entry.blade.php +++ b/resources/views/infolists/components/json-entry.blade.php @@ -6,12 +6,13 @@
diff --git a/src/Forms/Components/JsonInput.php b/src/Forms/Components/JsonInput.php index aabcc27..ff59f2e 100644 --- a/src/Forms/Components/JsonInput.php +++ b/src/Forms/Components/JsonInput.php @@ -20,4 +20,15 @@ class JsonInput extends Field use HasLineWrapping; protected string $view = 'filament-json-field::forms.components.json-input'; + + public function setUp(): void + { + parent::setUp(); + + $this + ->rules(['array']) + ->validationMessages([ + 'array' => __('The :attribute must be valid JSON.'), + ]); + } } diff --git a/tests/JsonEntryFieldTest.php b/tests/JsonEntryFieldTest.php index 5f591de..474ad01 100644 --- a/tests/JsonEntryFieldTest.php +++ b/tests/JsonEntryFieldTest.php @@ -38,6 +38,18 @@ expect($field->getHasLineNumbers())->toBe(true); }); +it('can have line wrapping code ', function () { + $field = JsonEntry::make('json'); + + expect($field->getHasLineWrapping())->toBe(true); + + $field->lineWrapping(false); + expect($field->getHasLineWrapping())->toBe(false); + + $field->lineWrapping(true); + expect($field->getHasLineWrapping())->toBe(true); +}); + it('can have code ', function () { $field = JsonEntry::make('json'); diff --git a/tests/JsonInputFieldTest.php b/tests/JsonInputFieldTest.php index 82f7e2a..0c5d728 100644 --- a/tests/JsonInputFieldTest.php +++ b/tests/JsonInputFieldTest.php @@ -38,6 +38,18 @@ expect($field->getHasLineNumbers())->toBe(true); }); +it('can have line wrapping code ', function () { + $field = JsonInput::make('json'); + + expect($field->getHasLineWrapping())->toBe(true); + + $field->lineWrapping(false); + expect($field->getHasLineWrapping())->toBe(false); + + $field->lineWrapping(true); + expect($field->getHasLineWrapping())->toBe(true); +}); + it('can have code ', function () { $field = JsonInput::make('json');