1# FormLink 2 3The **FormLink** component is provided for interactions between static widgets and widget providers. It supports three types of events: router, message, and call. 4 5> **NOTE** 6> 7> - This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8> 9> - This component can be used only in static widgets. 10> 11 12## Required Permissions 13 14None 15 16## Child Components 17 18This component supports only one child component. 19 20## APIs 21 22FormLink(options: FormLinkOptions) 23 24**Widget capability**: This API can be used in ArkTS widgets since API version 10. 25 26**Atomic service API**: This API can be used in atomic services since API version 11. 27 28**System capability**: SystemCapability.ArkUI.ArkUI.Full 29 30**Parameters** 31 32| Name | Type | Mandatory | Description | 33| --------- | ------------------------------- | ---- | ------ | 34| options | [FormLinkOptions](#formlinkoptions) | Yes | Widget information.| 35 36## FormLinkOptions 37 38**Atomic service API**: This API can be used in atomic services since API version 11. 39 40**System capability**: SystemCapability.ArkUI.ArkUI.Full 41 42| Name | Type| Mandatory| Description | 43| ----------- | -------- | ---- | ------------------------------------------------------------ | 44| action | string | Yes | Action type.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../../apis-form-kit/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.<br>- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility (whose launch type must be [singleton](../../../application-models/uiability-launch-type.md#singleton)) of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../../../security/AccessToken/permissions-for-all.md#ohospermissionkeep_background_running) permission.<br>**NOTE**<br>Whenever possible, avoid using the router event to refresh the widget UI.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 10.| 45| moduleName | string | No | Name of the target module when action is **"router"** or **"call"**.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 10.| 46| bundleName | string | No | Name of the target bundle when action is **"router"** or **"call"**.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 10.| 47| abilityName | string | No | Name of the target UIAbility when action is **"router"** or **"call"**.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 10.| 48| uri<sup>11+</sup> | string | No | URI of the target UIAbility when action is **"router"**. If both **uri** and **abilityName** are set, **abilityName** takes precedence.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 11.| 49| params | Object | No | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter must be set and its value type must be string.<br>**NOTE**<br>Whenever possible, avoid using **params** to transfer internal state variables of widgets.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 10.| 50 51## Attributes 52 53The [universal attributes](ts-universal-attributes-size.md) are supported. 54 55## Events 56 57The [universal events](ts-universal-events-click.md) are not supported. 58 59## Example 60 61```ts 62@Entry 63@Component 64struct FormLinkDemo { 65 build() { 66 Column() { 67 Text("This is a static widget").fontSize(20).margin(10) 68 69 // The router event is used to redirect to the specified UIAbility from the static widget. 70 FormLink({ 71 action: "router", 72 abilityName: "EntryAbility", 73 params: { 74 'message': 'testForRouter' // Customize the message to send. 75 } 76 }) { 77 Button("router event").width(120) 78 }.margin(10) 79 80 81 // The message event triggers the onFormEvent callback of FormExtensionAbility. 82 FormLink({ 83 action: "message", 84 abilityName: "EntryAbility", 85 params: { 86 'message': 'messageEvent' // Customize the message to send. 87 } 88 }) { 89 Button("message event").width(120) 90 }.margin(10) 91 92 93 // The call event is used to call the specified method in the UIAbility. 94 FormLink({ 95 action: "call", 96 abilityName: "EntryAbility", 97 params: { 98 'method': 'funA', // Set the name of the method to call in the EntryAbility. 99 'num': 1 // Set other parameters to be passed in. 100 } 101 }) { 102 Button("call event").width(120) 103 }.margin(10) 104 105 // The router event is used to redirect to the specified UIAbility from the static widget through deep linking. 106 FormLink({ 107 action: "router", 108 uri: 'example://uri.ohos.com/link_page', 109 params: { 110 message:'router msg for static uri deeplink' // Customize the message to send. 111 } 112 }) { 113 Button("deeplink event").width(120) 114 }.margin(10) 115 } 116 .justifyContent(FlexAlign.Center) 117 .width('100%').height('100%') 118 } 119} 120``` 121 122 123 124The following is an example of **uris** configuration in the [module.json5](../../../quick-start/module-configuration-file.md#skills) file of the target application: 125 126```json 127"abilities": [ 128 { 129 "skills": [ 130 { 131 "uris": [ 132 { 133 "scheme": "example", 134 "host": "uri.ohos.com", 135 "path": "link_page" 136 }, 137 ] 138 } 139 ], 140 } 141] 142``` 143