1# @ohos.application.formProvider (formProvider) 2 3The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release. 4 5> **NOTE** 6> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7> This module is deprecated since API version 9. You are advised to use [formProvider](js-apis-app-form-formProvider.md) instead. 8 9## Modules to Import 10 11```ts 12import formProvider from '@ohos.application.formProvider'; 13``` 14 15## setFormNextRefreshTime 16 17setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void 18 19Sets the next refresh time for a widget. This API uses an asynchronous callback to return the result. 20 21**System capability**: SystemCapability.Ability.Form 22 23**Parameters** 24 25 | Name| Type | Mandatory| Description | 26 | ------ | ------ | ---- | ------------------------------------- | 27 | formId | string | Yes | Widget ID. | 28 | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 29 | callback | AsyncCallback<void> | Yes| Callback used to return the result.| 30 31**Example** 32 33 ```ts 34 import Base from '@ohos.base' 35 36 let formId: string = '12400633174999288'; 37 formProvider.setFormNextRefreshTime(formId, 5, (error: Base.BusinessError) => { 38 if (error.code) { 39 console.error(`formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}`); 40 } 41 }); 42 ``` 43 44## setFormNextRefreshTime 45 46setFormNextRefreshTime(formId: string, minute: number): Promise<void> 47 48Sets the next refresh time for a widget. This API uses a promise to return the result. 49 50**System capability**: SystemCapability.Ability.Form 51 52**Parameters** 53 54 | Name| Type | Mandatory| Description | 55 | ------ | ------ | ---- | ------------------------------------- | 56 | formId | string | Yes | Widget ID. | 57 | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 58 59**Return value** 60 61 | Type | Description | 62 | ------------- | ---------------------------------- | 63 | Promise\<void> | Promise that returns no value. | 64 65**Example** 66 67 ```ts 68 import Base from '@ohos.base' 69 70 let formId: string = '12400633174999288'; 71 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 72 console.log('formProvider setFormNextRefreshTime success'); 73 }).catch((error: Base.BusinessError) => { 74 console.error(`formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}`); 75 }); 76 ``` 77 78## updateForm 79 80updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void 81 82Updates a widget. This API uses an asynchronous callback to return the result. 83 84**System capability**: SystemCapability.Ability.Form 85 86**Parameters** 87 88 | Name| Type | Mandatory| Description | 89 | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 90 | formId | string | Yes | ID of the widget to update.| 91 | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 92 | callback | AsyncCallback<void> | Yes| Callback used to return the result.| 93 94**Example** 95 96 ```ts 97 import Base from '@ohos.base'; 98 import formBindingData from '@ohos.application.formBindingData'; 99 100 let formId: string = '12400633174999288'; 101 let param: Record<string, string> = { 102 'temperature': '22c', 103 'time': '22:00' 104 } 105 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 106 formProvider.updateForm(formId, obj, (error: Base.BusinessError) => { 107 if (error.code) { 108 console.error(`formProvider updateForm, error: ${JSON.stringify(error)}`); 109 } 110 }); 111 ``` 112 113## updateForm 114 115updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> 116 117Updates a widget. This API uses a promise to return the result. 118 119**System capability**: SystemCapability.Ability.Form 120 121**Parameters** 122 123 | Name| Type | Mandatory| Description | 124 | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 125 | formId | string | Yes | ID of the widget to update.| 126 | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 127 128**Return value** 129 130| Type | Description | 131| -------------- | ----------------------------------- | 132| Promise\<void> | Promise that returns no value.| 133 134**Example** 135 136 ```ts 137 import formBindingData from '@ohos.application.formBindingData'; 138 import Base from '@ohos.base' 139 140 let formId: string = '12400633174999288'; 141 let param: Record<string, string> = { 142 'temperature': '22c', 143 'time': '22:00' 144 } 145 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 146 formProvider.updateForm(formId, obj).then(() => { 147 console.log('formProvider updateForm success'); 148 }).catch((error: Base.BusinessError) => { 149 console.error(`formProvider updateForm, error: ${JSON.stringify(error)}`); 150 }); 151 ``` 152 153 154