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(value: { 23 action: string; 24 moduleName?: string; 25 bundleName?: string; 26 abilityName: string; 27 params: Object; 28}) 29 30**Parameters** 31 32| Name | Type| Mandatory| Description | 33| ----------- | -------- | ---- | ------------------------------------------------------------ | 34| 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/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](../../application-models/uiability-launch-type.md) must be 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/permission-list.md#ohospermissionkeep_background_running) permission.| 35| moduleName | string | No | Name of the target module when **action** is **"router"** or **"call"**. This parameter is optional. | 36| bundleName | string | No | Name of the target bundle when **action** is **"router"** or **"call"**. This parameter is optional. | 37| abilityName | string | Yes | Name of the target UIAbility when **action** is **"router"** or **"call"**. This parameter is mandatory.| 38| params | Object | Yes | 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 (mandatory) must be set and its value type must be string.| 39 40## Attributes 41 42The [universal attributes](ts-universal-attributes-size.md) are supported. 43 44## Events 45 46The [universal events](ts-universal-events-click.md) are not supported. 47 48## Example 49 50```ts 51@Entry 52@Component 53struct FormLinkDemo { 54 build() { 55 Column() { 56 Text("This is a static widget").fontSize(20).margin(10) 57 58 // The router event is used to redirect to the specified UIAbility from the static widget. 59 FormLink({ 60 action: "router", 61 abilityName: "EntryAbility", 62 params: { 63 'message': 'testForRouter' // Customize the message to send. 64 } 65 }) { 66 Button("router event").width(120) 67 }.margin(10) 68 69 70 // The message event triggers the onFormEvent callback of FormExtensionAbility. 71 FormLink({ 72 action: "message", 73 abilityName: "EntryAbility", 74 params: { 75 'message': 'messageEvent' // Customize the message to send. 76 } 77 }) { 78 Button("message event").width(120) 79 }.margin(10) 80 81 82 // The call event is used to call the specified method in the UIAbility. 83 FormLink({ 84 action: "call", 85 abilityName: "EntryAbility", 86 params: { 87 'method': 'funA', // Set the name of the method to call in the EntryAbility. 88 'num': 1 // Set other parameters to be passed in. 89 } 90 }) { 91 Button("call event").width(120) 92 }.margin(10) 93 } 94 .justifyContent(FlexAlign.Center) 95 .width('100%').height('100%') 96 } 97} 98``` 99 100 101