angular icon indicating copy to clipboard operation
angular copied to clipboard

angular-formio: How to integrate formbuilder component to my application

Open bmadhan90 opened this issue 8 years ago • 20 comments

Hi Travist,

I am new to formio , It is possible to integrate formbuilder component to my application.

bmadhan90 avatar May 24 '18 05:05 bmadhan90

@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

YuryRybakSoftensity avatar May 31 '18 12:05 YuryRybakSoftensity

@bmadhan90 Did it help you?

YuryRybakSoftensity avatar Jun 07 '18 14:06 YuryRybakSoftensity

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 avatar Jun 08 '18 07:06 bmadhan90

@bmadhan90 Use builder.setDisplay(display), where display is 'form' or 'builder'.

YuryRybakSoftensity avatar Jun 08 '18 12:06 YuryRybakSoftensity

@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'); } }

bmadhan90 avatar Jun 11 '18 02:06 bmadhan90

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)

bmadhan90 avatar Jun 11 '18 12:06 bmadhan90

@YuryRybakSoftensity I am waiting for help on same question. Please help.

kikkiraj avatar Jun 13 '18 16:06 kikkiraj

@bmadhan90 are you able to figure it out. Please share your experience.

kikkiraj avatar Jun 18 '18 17:06 kikkiraj

@kikkiraj I am also still searching for solution.

wizard form rendering working.

bmadhan90 avatar Jun 19 '18 02:06 bmadhan90

@bmadhan90 yes rendering works for me too.

kikkiraj avatar Jun 22 '18 15:06 kikkiraj

@kikkiraj Have you solved the problem? Please share your experience.

indingpig avatar Aug 15 '18 00:08 indingpig

@bmadhan90 Have you solved the problem? I search for solution too, Can you share your experience?

indingpig avatar Aug 15 '18 02:08 indingpig

@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 avatar Aug 15 '18 06:08 indingpig

@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 avatar Aug 16 '18 12:08 kikkiraj

@kikkiraj here is the code. https://github.com/indingpig/angularApp

indingpig avatar Aug 16 '18 14:08 indingpig

Both the Angular Demo and the Starter Kit both implement the new Form manager module.

travist avatar Sep 05 '18 04:09 travist

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.

Theaggarwal avatar Jul 04 '19 08:07 Theaggarwal

Sushil,

Thanks for reaching out!

Can you please open this item as a new issue?

Thanks.

wag110894 avatar Jul 07 '19 21:07 wag110894

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

dev-thinks avatar Jun 24 '20 04:06 dev-thinks

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>

dev-thinks avatar Jun 24 '20 04:06 dev-thinks