angular icon indicating copy to clipboard operation
angular copied to clipboard

Customizations in Form builder

Open Theaggarwal opened this issue 7 years ago • 4 comments

In my angular 7 application, i included the "angular-formio": "3.17.0" and "formiojs": "3.21.5" npm packages. Now builder is rendering well but questions is - how to do customizations to it.

<form-builder [form]="formDefinition">

in component, I set value something like below, this.formDefinition = {"components": [{ "input": true, "inputType": "checkbox", "tableView": true, "hideLabel": false, "label": "Add a new charity", "key": "IsNewCharity", "defaultValue": false, "protected": false, "persistent": true, "validate": { "required": false }, "type": "checkbox", "tags": [], "conditional": { "show": "", "when": null, "eq": "" }, "lockKey": true, "datagridLabel": true, "clearOnHide": true, "autofocus": false, "dataGridLabel": false, "hidden": false, "name": "", "value": "", "labelPosition": "right", "properties": {} }}

Builder is rendering well.

Now question is how to do customization to it. Example

  1. How to hide components Ex - i need to hide File component from builder
  2. How to change Section heading, ex- rename 'basic components' to 'Level 1 components'

Can we move component from 1 section to another? if so, how? Please provide links to follow..

Theaggarwal avatar Nov 21 '19 04:11 Theaggarwal

@Theaggarwal for hiding the components, you have to set options and set the custom builder json like this

In .html: <form-builder [form]="form" [options]="builder">

In .ts file: public builder: Object = { builder: { premium: { components: { file: false}} //set file to false to hide file component inside premium section } };

see this link for setting custom builder json

muthuML avatar Nov 21 '19 07:11 muthuML

Thanks a lot @muthuML it works... but with a little change.. ( advanced instead of premium)

public formBuilderConfig: any = { builder: { advanced: { components: { file: false } } } };

Theaggarwal avatar Nov 21 '19 19:11 Theaggarwal

Does anyone know how to change Section heading, ex- rename 'basic components' to 'Level 1 components' ??

Theaggarwal avatar Nov 21 '19 19:11 Theaggarwal

Thanks all.. get the solution of my above question as well.. using above fix and https://formio.github.io/formio.js/app/examples/custombuilder.html

image

Theaggarwal avatar Nov 21 '19 19:11 Theaggarwal