Generating a SmartForm using the CLI Tool

Custom Smart Form components can be easily generated using the SmartComponents CLI tool. To generate a custom Smart Form:

  • open your favourite terminal

  • change directory to the root of your project

  • run the following command and follow the instructions:

scl generate form # Below is a sample of what a Smart Form generation process might look like: ? Form name: HelloWorld ? What is your form's ID? helloWorld ? How would you like to define your form's template? Using a JSON layout ? Form Layout URL: /SmartForm/Form/helloWorld ? Would you also like to include a client side NG route? No ? Please enter your service URI: http://localhost:8820 ? Authentication Type: Forms ? Please enter your username: demo ? Please enter your password: [hidden] ? Would you like to save this configuration? Your password will be encrypted and stored outside of your project. No

The form should now be generated under src/app/forms/hello-world. If you have chosen a frontend JSON layout, a file named hello-world.layout.json will have been generated at the path specified at the “Form Layout URL” step. In this case, frontend:// will be resolved to src.

Example:

frontend://assets/hello-world.layout.json // resolves to <project_root>/src/assets/hello-world.layout.json

Additional Information

Do not append the suffix “Form” to your component name. This will be added automatically by the generator.

The form ID may be anything you like - as long as there are no routes or layouts associated with that form ID in the backend. If there are, then the form using this form ID should implement the expected behaviour for the route/layout set in the backend.

The form layout URL may be entered in one of three ways:

  • absolute URL

  • relative (to your service URI) URL

  • using the frontend:// notation - in this case, “frontend://” will be replaced with the root web URL found in the browser.

When generating a Smart Form, you may either choose to work with a JSON layout, or a HTML layout.