Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Ability to use ->json() helper on code field to support JSON #3

Open
Cannonb4ll opened this issue May 3, 2022 · 0 comments
Open

Ability to use ->json() helper on code field to support JSON #3

Cannonb4ll opened this issue May 3, 2022 · 0 comments

Comments

@Cannonb4ll
Copy link

As per discussed, to be able to load in JSON you'll need to do like this:

  CodeEditor::make('metadata')->afterStateHydrated(function ($state, $set) {
      $set('metadata', json_encode($state));
  })
      ->dehydrateStateUsing(fn ($state) => (array) json_decode($state))
      ->required(),

It would be nice if that could be packed up to:

CodeEditor::make('metadata')->json()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant