# certara-form



<!-- Auto Generated Below -->


## Overview

Component to wrap form fields with built-in error messaging

## Properties

| Property                 | Attribute                  | Description                                                                                                               | Type      | Default                            |
| ------------------------ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------- | ---------------------------------- |
| `globalErrorDescription` | `global-error-description` | Body of error banner                                                                                                      | `string`  | `DEFAULT_GLOBAL_ERROR_DESCRIPTION` |
| `globalErrorHeadline`    | `global-error-headline`    | Headline of error banner                                                                                                  | `string`  | `DEFAULT_GLOBAL_ERROR_HEADLINE`    |
| `preventDefault`         | `prevent-default`          | Stop default form submission behavior. Necessary for server validation and custom form submission behavior via javascript | `boolean` | `false`                            |
| `showGlobalError`        | `show-global-error`        | Option to disable error banner                                                                                            | `boolean` | `true`                             |


## Events

| Event                   | Description                                                                                                                                | Type                                  |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |
| `certaraCustomValidate` | Emitted when field-level errors are applied programmatically (e.g. via setInputErrors); detail carries the errors map keyed by input name. | `CustomEvent<CustomFormSubmitDetail>` |
| `certaraSubmit`         | Emitted when the form passes constraint validation on submit; detail contains the underlying HTMLFormElement.                              | `CustomEvent<FormSubmitDetail>`       |
| `certaraValidate`       | Emitted when submit is attempted but the form fails constraint validation, so child inputs can show or hide error messages.                | `CustomEvent<any>`                    |


## Methods

### `setGlobalError(headline: string, description: string) => Promise<void>`

Method to programatically set the global error. Useful for passing global errors for server validation

#### Parameters

| Name          | Type     | Description |
| ------------- | -------- | ----------- |
| `headline`    | `string` |             |
| `description` | `string` |             |

#### Returns

Type: `Promise<void>`



### `setInputErrors(errors: ErrorObj) => Promise<void>`

Method to pass errors down to inputs in the form. The errors object schema should be { formInputName: 'error message' }

#### Parameters

| Name     | Type       | Description |
| -------- | ---------- | ----------- |
| `errors` | `ErrorObj` |             |

#### Returns

Type: `Promise<void>`



### `setIsInvalid(isInvalid: boolean) => Promise<void>`

Method to programatically set the invalidity state of the form. Useful for dealing with server side form validation.

#### Parameters

| Name        | Type      | Description |
| ----------- | --------- | ----------- |
| `isInvalid` | `boolean` |             |

#### Returns

Type: `Promise<void>`




## Dependencies

### Depends on

- [certara-alert](../alert)

### Graph
```mermaid
graph TD;
  certara-form --> certara-alert
  certara-alert --> certara-close-button
  style certara-form fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------


