# FormComposerV2

## **Overview** <a href="#undefined" id="undefined"></a>

Follow the steps below to customise the various forms.

### **Usage Contexts**&#x20;

* Citizen Complaint Creation – Multi-step form.
* Employee Complaint Creation – Single-step form.
* Workflow Actions – Used for updating complaint status (modal forms).

### **Supported Field Types**

* Common: `text`, `number`, `radio`, `checkbox`, `select`, `toggle`, `password`
* Special: `time`, `geolocation`, `search`, `amount`, `mobileNumber`, `multiselectdropdown`
* Custom: `component`, `apidropdown`, `locationdropdown`, `dateRange`

## **Steps**

1. **Add New Field to Existing Card**

   ```
   {
     inline: true,
     label: "CS_COMPLAINT_POSTALCODE_DETAILS",
     isMandatory: false,
     type: "number",
     disable: false,
     populators: {
       name: "postalCode",
       maxlength: 6,
       validation: { pattern: /^[1-9][0-9]{5}$/i }
     }
   }
   ```
2. **Add New Card**

   ```
   {
     head: "CS_COMPLAINT_LOCATION_DETAILS",
     body: [
       {
         inline: true,
         label: "CS_COMPLAINT_DETAILS_ADDRESS_1_DETAILS",
         isMandatory: false,
         type: "text",
         key: "AddressOne",
         disable: false,
         populators: { name: "AddressOne", maxlength: 64 }
       }
     ]
   }
   ```
3. **Add Custom Component**
   * Create component (must accept `t, config, onSelect` props)
   * Register in `Module.js`:

     ```
     const componentsToRegister = {
       PGRBoundaryComponent: BoundaryComponent
     };
     ```
   * Use in config:

     ```
     {
       type: "component",
       isMandatory: true,
       component: "PGRBoundaryComponent",
       key: "SelectedBoundary",
       label: "Boundary",
       populators: { name: "SelectedBoundary" }
     }
     ```

&#x20;     &#x20;

&#x20;  The reference  for `PGRBoundaryComponent`  [Source Code ](https://github.com/egovernments/Citizen-Complaint-Resolution-System/blob/SB-PGR-CITIZEN/frontend/micro-ui/web/micro-ui-internals/packages/modules/pgr/src/components/BoundaryComponent.js)&#x20;

1. **Dynamic Field Updates**
   * Use `preProcessMDMSConfig` to change field options/values based on another field’s selection.
2. **Data Transformation for API**
   * Add your field mapping to `transform` function (in `utils/index.js`) to include in API payload.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digit.org/complaints-management/complaints-resolution-v2.10/deploy/customise/frontend/customise-ui/formcomposerv2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
