Coder Social home page Coder Social logo

Comments (4)

elijahworkz avatar elijahworkz commented on August 17, 2024 1

@Naoray you're right. I forgot to add that you need to get the property 'data' from the top JSON field.

Like this:

  1. don't wrap JSON::make() in [] so it would look like this:
Panel::make('Brand Settings', 
                JSON::make('brand_settings', [
                    Image::make('Logo')->disk('public'),
                    Color::make('Primary Color')->swatches(),
                    Color::make('Secondary Color')->swatches(),
                ])->data,
            ),
  1. if you need other fields inside the Panel you can use splat operator like this:
Panel::make('Brand Settings', [
                Text::make('Field'),
                ...JSON::make('brand_settings', [
                    Image::make('Logo')->disk('public'),
                    Color::make('Primary Color')->swatches(),
                    Color::make('Secondary Color')->swatches(),
                ])->data,
            ]),

from nova-json.

Naoray avatar Naoray commented on August 17, 2024 1

@elijahworkz thanks. That works 🤝

from nova-json.

elijahworkz avatar elijahworkz commented on August 17, 2024

There are a couple of way to solve this without changing the code

  1. don't wrap JSON::make() in [] so it would look like this:
Panel::make('Brand Settings', 
                JSON::make('brand_settings', [
                    Image::make('Logo')->disk('public'),
                    Color::make('Primary Color')->swatches(),
                    Color::make('Secondary Color')->swatches(),
                ]),
            ),
  1. if you need other fields inside the Panel you can use splat operator like this:
Panel::make('Brand Settings', [
Text::make('Field'),
                ...JSON::make('brand_settings', [
                    Image::make('Logo')->disk('public'),
                    Color::make('Primary Color')->swatches(),
                    Color::make('Secondary Color')->swatches(),
                ]),
            ]),

added section to readme.md #4

from nova-json.

Naoray avatar Naoray commented on August 17, 2024

@elijahworkz I tested both approaches and none of them worked. First approach did throw errors related to the fact that the JSON class does not inherit from Field. Second approach is not possible because you can't deconstruct associative arrays with ...

from nova-json.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.