dschnelldavis / angular2-json-schema-form

Angular 2 JSON Schema Form builder
MIT License
285 stars 177 forks source link

i write this code for angular json schema form #227

Open varshildoshi opened 6 years ago

varshildoshi commented 6 years ago

{ "type" : "button", "title" : "save", onClick : "exampleOnSubmitFn($event)" }

but does not work properly

Alex130 commented 6 years ago

Hi, can you provide more information about your form (schema, data, layout)? As a guess, you probably want this for a submit button : "type": "submit", "style": "btn-info", "title" : "save", "onClick" : exampleOnSubmitFn($event)

varshildoshi commented 6 years ago

yes,but i want to call my own method through submit button,but its not working..

varshildoshi commented 6 years ago

i take one json for generate layout using typescript & angular 4,so if i create my own button for reset,submit,next & save,so need my own function for event,but in my json function is not work proprly...so give me solution..

varshildoshi commented 6 years ago

i got the solution...

varshildoshi commented 6 years ago

but one more thing, this is my birthdate json "birthdate" : { "type" : "date" }, this is my layout json for birthdate { "key" : "birthdate", "type" : "date", "flex" : "3 3 100px" }, but it gives me wrong data for date,ex: if i select 3/4/2003 it returns 2/4/2003,what can i do for that??

varshildoshi commented 6 years ago

if i take type="string" & layout type="date" its not working..

varshildoshi commented 6 years ago

& i use angular material design for that..

Alex130 commented 6 years ago

"but it gives me wrong data for date,ex: if i select 3/4/2003 it returns 2/4/2003,what can i do for that??"

What timezone are you using? it is related to #191 . The bug is not fixed but I wrote an override for my own project. Feel free to use it. datePickerOverride.zip I might submit a pull request to do things cleanly when I have the time.

In app.modules.ts :

{ provide: MAT_DATE_LOCALE, useValue: 'fr-FR' },
    { provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS},
    { provide: DateAdapter, useClass : MomentDateAdapter }

and

export class AppModule {
  constructor(wl: WidgetLibraryService) {
    wl.registerWidget('date', NewMaterialDatepickerComponent);
  }
}

Replace fr by your desired language The code was for my usage only, with Moments.js, and not fully tested, but I hope it helps

Alex130 commented 6 years ago

Btw, using your own function on Submit is done in the template's json-schema-form tag :

<json-schema-form framework="material-design" [layout]="layout" loadExternalAssets="false" [schema]="userScheme" [(ngModel)]="currentUser" (onSubmit)="submit($event)"></json-schema-form>

Note the (onSubmit) binding. The event Object contains your validated and submitted form.

varshildoshi commented 6 years ago

i am not sure,so plz send me full code with output for datapicker.. plz...

varshildoshi commented 6 years ago

and you can share related link for datepicker...for better understanding

Alex130 commented 6 years ago

Hi, Material Datepicker this is the documentation for Material Datepicker. Note the DateAdapter, which is not configurable in angular2-json-schema-form in its current state. After modifying your app.modules as above, the code in my previous comment is all you need to use the overriden class automatically, and the event in your submit function should contain the correct date (with your locale and the correct date for your timezone). You can keep your schema and layout as it is in this post .

varshildoshi commented 6 years ago

Thanks..Alex130

varshildoshi commented 6 years ago

one more thing..Alex130 I want to use tinymce in my project,so if u have any idea about it..plz tell me...in angular 4,angular material

Alex130 commented 6 years ago

Hi, it's not implemented yet, you would need to write your own widget, you can see the developer of the module writes about it in the future versions section on the main github page. If you do, please contribute to it if you can

varshildoshi commented 6 years ago

ok..sure.. but do you know how to define & use my own css in json using angular material

Alex130 commented 6 years ago

I did a pull request about this a while ago : #221 Some attributes are already bound and you can use them, I added some of the missing ones, check it out.

varshildoshi commented 6 years ago

hi Alex130 i want to help from you.. i want to create Drag & Drop in angular 4 using typescript,but some problem occures.. when i drop any text view generate text view in dropzone..it is using angular material.. if you know about that plz tell me..i am use jquery for drag & drop with angular material..so plz help me..