Aaltuj / VxFormGenerator

The library contains a component, that nests itself into the Blazor EditForm instead of a wrapper around the EditForm. The component is able to generate a form based on a POCO or a ExpandoObject. Because of this architecture the library provides the developer flexibility and direct usage of the EditForm.
MIT License
119 stars 36 forks source link

Add a WASM example #16

Open Aaltuj opened 3 years ago

Aaltuj commented 3 years ago

By popular rquest add a WASM example.

VxFormgenerator should support WASM.

mserey commented 3 years ago

Hi, I need implement this feature but in my WASM project. but through a configurator that saves this configuration in the database. What do you recommend me. is this library available in nuget?

Aaltuj commented 3 years ago

hi @mserey, You can find the nugets here. The readme in the develop branch contains the WASM Setup, no release yet, but 0.4.0 should work with those instructions.

Not sure what you mean with 'but through a configurator that saves this configuration in the database'

mserey commented 3 years ago

Hi Instead of drawing the form through a poc, we must do it dynamically through a form builder whose configuration will be saved in the database. We thought to use expandobject generating the object at runtime obtaining the parameters from the database

Aaltuj commented 3 years ago

Aah I see what you are trying to accomplish. That is indeed the usecase for the expando object. However #5 is on the roadmap, here the idea is that the ExpandoObject will be deprecated, in favour for a JSON based schema. (this should be more a less a serialized object containing Built-in classes. Like the VxFormElementLayoutAttribute and the ValidationAttributes)

{
   "nameOfProperty": { // name of the property
     "attributes": 
                    {"MinLength": { "Length": 5  }, 
                     "Required":{}, 
                     "VxFormElementLayout": {  // VxFormElementLayoutAttribute  
                                          "label": "",
                                          "order": 0
                                          }",

                     }, // Attributes
     "type": "String", // Or a custom type
     "value": "The value of the property" // could be a complex type
    }
}

// Following this approach it is easier to parse and we could create nested objects as well, supporting VxGroup etc..

Under the hood there is a converter that use a 'empty' base class, where the properties would be added dynamicly via reflection. This converter is can be built separately from the generator and create an object that is usable with the form generator.

This also allows to construct an object with reflection added attributes, so no need for the component to handle the expandoobjects anymore. It is just an annotated object this way, removing complexity in the component and easier external definition storage.

so... to make a long story short: I recommend you try the described approach up here. Otherwise use the expando object way, but that doesn't support validations...

Feel free to add an concept of your solution in the issue #5 so we can discuss your proposed implementation . It would be nice if you could take issue #5 some steps further.

mserey commented 3 years ago

ok I'll take your recommendation and try to dynamically build an object through reflection