Update Form Component

The UpdateFormComponent is part of the Form Package, designed to handle entity updates dynamically. It leverages the GenericFormBuilderComponent to generate forms dynamically based on a provided schema and provides seamless integration with navigation, submission logic, and templates for customization.

How to use the component in your app :

  1. import the component :

import {UpdateFormComponent} from '@tradinos/cms-frontend-form';
  1. The selector for component , like it :

<lib-update-form ></lib-update-form >

Features

  1. Dynamic Form Generation:

    • Uses the GenericFormBuilderComponent to generate forms dynamically based on a schema.

    • Supports pre-filled form fields with data from the result input.

  2. Custom Templates:

    • Allows developers to customize specific parts of the form using templates.

  3. Form Submission:

    • Handles submission logic, including transformations, validations, and API interactions.

    • Calls a service to update data and navigates upon success.

  4. Built-In Navigation:

    • Automatically integrates with Angular's router for navigation post-submission.

  5. Submit Button Control:

    • Provides the option to show or hide the submit button using the submitButton input.

  6. Loading State:

    • Supports a [loading] template slot to indicate form processing.

Inputs

Input

Type

Description

dataKey

string

The key used to uniquely identify the data being updated.

templates

{ [key: string]: TemplateRef<any> }

A dictionary of custom templates to customize specific parts of the form.

result

Result<T>

The initial data to pre-fill the form fields.

submitButton

boolean

Controls whether the submit button is displayed.

Methods

1. submit(): void

  • Description:

    • Handles form submission.

    • Retrieves the form data from the GenericFormBuilderComponent, validates and transforms it, then submits it via the service.

    • Navigates to the appropriate route upon successful submission.

Content Projection

Slot Name

Description

[loading]

Custom loading template displayed when the form is in a loading state (e.g., during submission).

Last updated