question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Complex FormPanel data?

See original GitHub issue

Let’s say I have a data class that looks like:

@Serializable
data class MyData(val myInt: Int, val myNestedData: NestedData)
@Serializable
data class MyNestedData(val myString: String)

Is it possible to have FormPanel represent the MyData class directly? Or do I need to unwind this data class such that it looks like:

@Serializable
data class MyFormPanelData(val myInt: Int, val myNestedData_myString: String)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rjaroscommented, Jul 8, 2019

Form<K> class uses Map<String, FormControl> internally to keep the data and it needs to create K class somehow (in the getData() method). We cannot just create an instance of generic K class in Kotlin nor in JS. Early implementations of KVision’s Form class required model class properties to be delegated to Map and required additional factory function in the constructor (see how it looked: https://github.com/rjaros/kvision-examples/blob/4c8553f91f9bb2f7b5df0255c56e1aec14963bc9/showcase/src/main/kotlin/com/example/FormTab.kt). Then I found out kotlinx.serialization had a Mapper class, which allowed to create K instance automagically, as long as it’s serializable. So I’ve integrated this solution, and the serialization requirement is a lot better than the previous one. I’m not sure it can be dropped without sacrificing the functionality, but I’m open to any suggestions.

1reaction
rjaroscommented, Jul 6, 2019

If the nested class has only one property (like in your example) it probably could be done with some effort. But if there are more properties I see no way to reference them and add form controls for them (FormPanel.add takes a field reference as a parameter).

The only thing I can imagine is to implement nested forms - such nested classes could be automatically mapped to nested forms. But it would be hard and would take a lot of work. It’s not impossible but I’m afraid it won’t be done anytime soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Form Design for Complex Applications | by Andrew Coyle
This article illustrates 13 different ways to present forms and explores the future of data input. Modal. Simple modals work well for forms...
Read more >
How to Implement Complex Form Data?
I'm looking for best practices on how to upload and send such a complex form with potentially dozens of songs to the server....
Read more >
Pass complex data from form submit? - Stack Overflow
I have a array of objects that each have like 5 fields and I want to send that array on a form ......
Read more >
Solved: Display complex data in Sharepoint Form
Solved: I have two use cases where I'm storing sets of data as a JSON array in a multi-line text field. I do...
Read more >
complexData of ui.form, Properties Webix Docs - Documentation
complexData. enables complex data parsing mode. boolean complexData;. Example. var form = webix.ui ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found