nova-issues icon indicating copy to clipboard operation
nova-issues copied to clipboard

[Request] MySQL/Postgres JSON Field Support

Open rkleinbc opened this issue 8 years ago • 7 comments

With Laravel's support for updating JSON fields, it would be great if Nova supported defining resource fields for data within a JSON column field (not just a code editor). Maybe a new JSON field type could accept an array mapping each JSON field key to an existing Nova field type. The JSON field could default to displaying as a separate Nova field panel.

Example (not sure if it's valid, but just an idea):

JSON::make('Options')->json(
   [ 
      'price' => Text::make('Price'),
      'color' => Select::make('Color')->options( \App\Color::getColors() )  
  ]
)

rkleinbc avatar Sep 04 '18 15:09 rkleinbc

We were actually talking about implementing something like this today for one of our projects that has a flexible JSON field. 👍

robmpreston avatar Sep 04 '18 16:09 robmpreston

There is a package that does this already

https://novapackages.com/packages/fourstacks/nova-repeatable-fields

willmkt avatar Sep 04 '18 17:09 willmkt

Is there anything like this except for relations? For example, my pet store contains a hasMany relation with pets. I can add x amount of pets to the store. Basically repeatable fields but with relations instead of a JSON payload that saves to a particular field. This would be extremely useful.

itstrueimryan avatar Sep 04 '18 20:09 itstrueimryan

In case you are interested we just released a package for this. Take a look. Issues and PRs welcome!

https://novapackages.com/packages/64robots/nova-json

beliolfa avatar Sep 05 '18 17:09 beliolfa

I think this should be handled by Nova instead of contrib packages. I try to add field options with array of object style

let simple = [
  {name: "size", values: ["sm", "md", "lg"]},
  {name: "fabric", values: ["cotton", "silk", "linen"]}
]

let nested = [
  {name: "color", values: [{ value: "#FF0000", label: 'Red' }, { value: "blue", label: "Blue" }, { value: "green": label: "Green" }]}
]

All contrib packages do not work, summary below:

Feature nsavinov/nova-json-schema-field fourstacks/nova-repeatable-fields 64robots/nova-json
Nova native field 👍
Array of object 👍
JSON schema 👍
Nested object

olragon avatar Sep 20 '18 09:09 olragon

Hey there! In order to keep this repository focused on bug reports, we auto-close feature requests and requests for help. Feel free to post your feature requests so others can discuss and add reactions. We'll keep an eye on them for later planning.

heyhemp avatar Feb 12 '19 17:02 heyhemp

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 19 '21 00:10 github-actions[bot]