bhch / django-jsonform

A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
https://django-jsonform.rtfd.io
BSD 3-Clause "New" or "Revised" License
307 stars 31 forks source link

Dynamic header generation for array items #149

Open ErikKoinberg opened 4 months ago

ErikKoinberg commented 4 months ago

It would be nice to have an option to generate dynamic headers when adding new items to an array. Perhaps a property called objectName or something like that is needed. For an object name "Book", it would be cool to get subheaders for the items like Book 1, Book 2 etc.

bhch commented 4 months ago

Any ideas how this can be implemented?

Only way I can think of is to execute a JS function every time a new item is added and that function will return a new header?

ErikKoinberg commented 4 months ago

Yes, I agree. The function will have to look at the schema for what the object type name is as well as how many instances there currently are in the data. With reordering or even duplications, this gets even trickier.