angular-formio: How to integrate formbuilder component to my application
Hi Travist,
I am new to formio , It is possible to integrate formbuilder component to my application.
@bmadhan90 Please consider to use https://formio.github.io/formio.js/docs/class/src/FormBuilder.js~FormBuilder.html https://github.com/formio/angular-formio/tree/master/demo/forms/builder
@bmadhan90 Did it help you?
Thanks. Used 2nd reference link to bind form builder.
One more question. How to change display type(form/wizard) in form builder? Any idea?
@bmadhan90 Use builder.setDisplay(display), where display is 'form' or 'builder'.
@YuryRybakSoftensity
Help me where to add,
HTML code as below <form-builder [form]="form" (change)="onChange($event)">
ts code as below import { Component, ElementRef, EventEmitter, ViewChild, OnInit } from '@angular/core';
@Component({ selector: 'app-form-builder', templateUrl: './form-builder.component.html', styleUrls: ['./form-builder.component.css'] }) export class FormBuilderComponent implements OnInit { @ViewChild('json') jsonElement?: ElementRef; public triggerRefresh: any;
public form: Object = { components: [], display: 'form' };
ngOnInit() { this.triggerRefresh = new EventEmitter(); }
onChange(event) { // console.log(event); // setDisplay('wizard'); this.jsonElement.nativeElement.innerHTML = ''; this.jsonElement.nativeElement.appendChild(document.createTextNode(JSON.stringify(event.form, null, 4)));
this.triggerRefresh.emit({
property: 'form',
value: this.form
});
}
// setDisplay(wizard: any); onSubmit(submission: any) { console.log('madhan'); } }
FormBuilderComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: this.form.setDisplay is not a function at FormBuilderComponent.push../src/app/form-builder/form-builder.component.ts.FormBuilderComponent.ngOnInit (form-builder.component.ts:22) at checkAndUpdateDirectiveInline (core.js:10097) at checkAndUpdateNodeInline (core.js:11363) at checkAndUpdateNode (core.js:11325) at debugCheckAndUpdateNode (core.js:11962) at debugCheckDirectivesFn (core.js:11922) at Object.eval [as updateDirectives] (FormBuilderComponent_Host.ngfactory.js? [sm]:1) at Object.debugUpdateDirectives [as updateDirectives] (core.js:11914) at checkAndUpdateView (core.js:11307) at callViewAction (core.js:11548)
@YuryRybakSoftensity I am waiting for help on same question. Please help.
@bmadhan90 are you able to figure it out. Please share your experience.
@kikkiraj I am also still searching for solution.
wizard form rendering working.
@bmadhan90 yes rendering works for me too.
@kikkiraj Have you solved the problem? Please share your experience.
@bmadhan90 Have you solved the problem? I search for solution too, Can you share your experience?
@bmadhan90 @kikkiraj I have solved the problem; just like this: HTML code as below: <button (click)="save()" class="btn default" type="button">save <form-builder [form]="form" (change)="onChange($event)">
ts code as below import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, EventEmitter } from '@angular/core';
@Component({ selector: 'app-formbuilder', templateUrl: './formbuilder.component.html', styleUrls: ['./formbuilder.component.css'] })
export class FormbuilderComponent implements OnInit {
public form: Object = { components: [], }; ngOnInit() { } save() { // this.http.post(); console.log(this.form); localStorage.setItem('formBuilderData', JSON.stringify(this.form)); } onChange(event) { }
}
@indingpig can you please share your formbuilder.component.html too. need a quick clarity, is your solution for display change? If yes then Select with [Form, Wizard] options are not part of <form-builder directive, then how did you fixed is the curious part.
Please share.
@kikkiraj here is the code. https://github.com/indingpig/angularApp
Both the Angular Demo and the Starter Kit both implement the new Form manager module.
I have angular 7 application. now i want to use Form-builder in my application. Since there is another library used in the proj that uses core-js-2.6.9 version. Now i know that If i use below version then application will work fine. "angular-formio": "3.16.0", "formiojs": "3.20.9",
Now, Problem is on using <formio> or <form-builder > , i am getting an error - 'form-builder' is not a known element. Please suggest where is the problem, In app module, i wrote the following: import { FormioGrid } from 'angular-formio/grid'; @NgModule({ imports: [FormioModule] ... Downloaded Angular-starter-kit sample code is working but not the actual. Can you please suggest @travist tagging others as they may help me - @YuryRybakSoftensity @bmadhan90 bmadhan90
404 Not found coming on url - https://github.com/formio/angular-formio/tree/master/demo/forms/builder.
Sushil,
Thanks for reaching out!
Can you please open this item as a new issue?
Thanks.
I have angular 7 application. now i want to use Form-builder in my application. Since there is another library used in the proj that uses core-js-2.6.9 version. Now i know that If i use below version then application will work fine. "angular-formio": "3.16.0", "formiojs": "3.20.9",
Now, Problem is on using
or , i am getting an error - 'form-builder' is not a known element. Please suggest where is the problem, In app module, i wrote the following: import { FormioGrid } from 'angular-formio/grid'; @NgModule({ imports: [FormioModule] ... Downloaded Angular-starter-kit sample code is working but not the actual. Can you please suggest @travist tagging others as they may help me - @YuryRybakSoftensity @bmadhan90 bmadhan90 404 Not found coming on url - https://github.com/formio/angular-formio/tree/master/demo/forms/builder.
Hope these 2 new urls helps here -
https://github.com/formio/angular-demo/tree/master/src/app/forms/builder
https://github.com/merobal/angular-formio-custom-demo/tree/master/src/app
For builder.setDisplay('form||wizard')
display is a field in form json-schema where we supply the list of components and others. I believe, by default it is picking up 'form' as display.
Just add a field (as display with form or wizard) in 'form' json or add it in the URL which supplies the json.
Something similar to this,
in component,
constructor() {
this.form = {display: 'wizard', components: []};
}
in template,
<form-builder [form]="form" (change)="onChange($event)"></form-builder>