Creating custom forms¶
Introduction¶
This tutorial will be useful for you if you need a form where the fields should interact, the layout has special features like tabs, etc.
Before reading this guide, make sure you have read:
- Suite 3.0 forms module.
- Angular style guide..
- Suite 3.0 standard form components: The ui and ux of each of the app should offer the same experience, that's why you must use the building blocks (components) that Suite 3.0 offers.
Create a new ui form component¶
Important
For this part we need a UI library for the "dumb" form component form.
In this part you are going to create your own component, which integrates with CVA.
-
If you need to create a form with a group of fields use the following schematic:
yarn nx workspace-generator form-component [form-name] --project [feature]-ui --formType group
-
If you need to create a form with a list of fields use the following schematic:
yarn nx workspace-generator form-component [form-name] --project [feature]-ui --formType array
-
If you need to create an special input use the following schematic:
yarn nx workspace-generator form-component [form-name] --project [feature]-ui --formType control
Tip
If you are adding a new form control component that could be shared to other apps contact the suite framework team, probably you are creating an standard form control.
For this tutorial we are going to create a FormGroup ui component with the user
profile fields and a custom layout using gdLayout
:
- Create the component:
Bash | |
---|---|
- import external modules and dependencies.
- Update the template
Configure a field to use the custom form¶
Once you finished with the UI component you can include the component into your form page.
- Import the module.
TypeScript | |
---|---|
- configure the field.
Summary¶
- You created a new form component using the suite 3.0 generators.
- You used the building blocks to add all the fields that you need.
- You added the custom component to your form page.