-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Forms Component #8
Comments
Ignoring implementations for a second, I'd be curious as to your stance toward JSON Schema as a potential base to generate forms from (or probably extended, as form libraries building off of it have generally done so far). Not that it is the only such OIM, but I'm not sure of good alternatives. If you would be interested in JSON Schema, I fear Formly isn't ideal for it since (1) you'd need to support it at the core to keep individual ng2 controls aware of validation bits they're responsible for, while (2) they want to remain OIM-agnostic (can't say put UI customization metadata into nested fields part of an array/object). angular-schema-form and react-jsonschema-form were made for JSON Schema, but even the former hadn't really gotten an ng2 implementation yet. Essentially I've been trying to do this right with JSON Schema and ng2, so would be curious as to your needs here. |
We haven't put together a comprehensive plan for forms yet, so this is interesting input. We know that Formly is interesting, but it does focus on some different things (like being able to template with various types of UI libraries instead of just material). One example for our applications will be to have a JSON object define the form so it can dynamically generate all of the fields (I'm not familiar with the term OIM but this seems to be very similar). We have an existing API that defines these fields and generates a form, that we'll want to upgrade to work with Covalent. There is some discovery here for us to understand the constraints and challenges. So yes, in general we're looking at a solution that marries together material form components and a JSON schema. If you have some design concepts or want to collaborate with this, we'd be happy to do some prototyping to see what we can figure out. This is likely one of those types of features that we'll build a simple solution that will need many iterations to polish for a more broad consumption. |
Yeah, I don't think anyone had heard of OIM, I also just found it on Formly's page linking to the above-mentioned podcast, which might have coined it. Since the podcast mentions multiple, them taking it from there probably also explains Formly's stance in not picking sides. In reality it's a much smaller space though -- the Jsonary mentioned in the podcast seems to be a UI library (afaict on the level of That isn't to say Formly doesn't have its own strengths compared to JSON Schema -- they were based on JS vs. JSON respectively, and the former obviously makes it easier to pass custom validation functions. That being said, existing form generation libraries have usually been inclined to add UI customization options on top, and I suppose at that point allowing JS objects (rather than just JSON serializations) so as to support custom validation functions should work just as well. I'll have to admit I'm not terribly familiar with Formly though, so there may be other relevant considerations. Any fields used in their example ( API endpoints' request GET parameters essentially just form one object (i.e. some keyed values), which without nesting (-> no arrays/objects) is relatively straight-forward. I already needed more if just to allow specifying request headers though (-> object). This shows where it can get harder -- taking into account parts of JSON Schema like:
As you're saying, you'd probably manage with something simpler as well. I'll try to see if I can migrate to Covalent and split my UI generation off for you to try, but failing that, you can check my components and controls for reference. I also just found this angular2-schema-form that may interest you as well. |
I've had it in the back of my head that we'll essentially model an object that follows the properties set forth by HTML form elements. I think that will be most useful going forward, and allow us to keep it thin. You're raising a number of things that I suspect will have to be iterative releases to figure out. This all really has to come in line with a REST API. Without clearing up the way the frontend and backend (regardless of platform) will both handle validation rules, I fear we're a few steps ahead on this discussion from our perspective. |
Yeah, fair enough. You mentioned doing a thin wrap of HTML form element properties -- which I guess might extend to wrapping Material components for their abstractions/additions. So this page contains a form example:
From your description I'm imagining a JSON-like equivalent like this, probably missing your intention...:
|
We don't have any documentation publicly about the API yet. That is a similar JSON example, though I don't have the specifics in mind yet. |
Alright. Curious how things will develop. :) |
Based on your thin wrapper comment, you may be also interested in this thread for examples of a few similar projects. |
Proposed first iteration on schema (used as our internal projects):
|
Guess that pretty much matches the html input attributes, so for internal implementation that should make things easy. In the event you'd be willing to put up with the native Date input, material2's That said, they wouldn't do boolean either (delegated to checkbox/toggle), so you might just wrap them and swap input based on type. |
…) (#204) * upstream dynamic forms without dates * added docs scaffolding for dynamic forms * added path mapping for `@covalent` * remove stepAttrs from dynamic form docs * added type and element to test things * added TD_DYNAMIC_FORMS constant * renamed enums and interfaces * added checkbox dynamic element * added dynamic slider element * test input element type * validate element name against special characters * duplicated name validation * added materially label to dynamic slider * added package.json * added blank README.md * changed imports to specific validators * use relative path for core.module (gulp-typescript complains) * replace relative core.module path with @covalent/core on build * added demos per group family of elements * set name as id in dynamic element * added doc blocks for dynamic-forms * updated properties docs in dynamic-forms * added docs for dynamic-forms * dynamic-forms.service unit test * added more exports to dynamic-forms * added unit tests for dynamic-forms.component * fix tslint errors * added README.md * fixed unit tests * added relative path to dynamic-forms components * favor md-input-container in dynamic-input * remove value and added thumbLabel on slider * added textarea dynamic component and updated docs * unit tests for dynamic-textarea * added dynamic select component + docs and demo * updated unit tests with select * updated README.md * update(dynamic-forms): Number support coming soon - upstream bug blocking it
Closing this since initial release will be in 0.10. Please open a new issue for enhancements. |
chore(Upgrade to Angular 5.2.0)
Possibly based off https://github.com/formly-js/ng2-formly
The text was updated successfully, but these errors were encountered: