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 | Time for the next refresh. The value must be greater than or equal to 5, in minutes. | 29 | callback | AsyncCallback<void> | Yes| Callback used to return the result.| 30 31**Example** 32 33 ```ts 34 import Base from '@ohos.base'; 35 import formProvider from '@ohos.application.formProvider'; 36 37 let formId: string = '12400633174999288'; 38 formProvider.setFormNextRefreshTime(formId, 5, (error: Base.BusinessError) => { 39 if (error.code) { 40 console.error(`formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}`); 41 } 42 }); 43 ``` 44 45## setFormNextRefreshTime 46 47setFormNextRefreshTime(formId: string, minute: number): Promise<void> 48 49Sets the next refresh time for a widget. This API uses a promise to return the result. 50 51**System capability**: SystemCapability.Ability.Form 52 53**Parameters** 54 55 | Name| Type | Mandatory| Description | 56 | ------ | ------ | ---- | ------------------------------------- | 57 | formId | string | Yes | Widget ID. | 58 | minute | number | Yes | Time for the next refresh. The value must be greater than or equal to 5, in minutes. | 59 60**Return value** 61 62 | Type | Description | 63 | ------------- | ---------------------------------- | 64 | Promise\<void> | Promise that returns no value. | 65 66**Example** 67 68 ```ts 69 import Base from '@ohos.base'; 70 import formProvider from '@ohos.application.formProvider'; 71 72 let formId: string = '12400633174999288'; 73 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 74 console.log('formProvider setFormNextRefreshTime success'); 75 }).catch((error: Base.BusinessError) => { 76 console.error(`formProvider setFormNextRefreshTime, error: ${JSON.stringify(error)}`); 77 }); 78 ``` 79 80## updateForm 81 82updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void 83 84Updates a widget. This API uses an asynchronous callback to return the result. 85 86**System capability**: SystemCapability.Ability.Form 87 88**Parameters** 89 90 | Name| Type | Mandatory| Description | 91 | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 92 | formId | string | Yes | ID of the widget to update.| 93 | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 94 | callback | AsyncCallback<void> | Yes| Callback used to return the result.| 95 96**Example** 97 98 ```ts 99 import Base from '@ohos.base'; 100 import formBindingData from '@ohos.application.formBindingData'; 101 import formProvider from '@ohos.application.formProvider'; 102 103 let formId: string = '12400633174999288'; 104 let param: Record<string, string> = { 105 'temperature': '22c', 106 'time': '22:00' 107 } 108 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 109 formProvider.updateForm(formId, obj, (error: Base.BusinessError) => { 110 if (error.code) { 111 console.error(`formProvider updateForm, error: ${JSON.stringify(error)}`); 112 } 113 }); 114 ``` 115 116## updateForm 117 118updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> 119 120Updates a widget. This API uses a promise to return the result. 121 122**System capability**: SystemCapability.Ability.Form 123 124**Parameters** 125 126 | Name| Type | Mandatory| Description | 127 | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 128 | formId | string | Yes | ID of the widget to update.| 129 | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 130 131**Return value** 132 133| Type | Description | 134| -------------- | ----------------------------------- | 135| Promise\<void> | Promise that returns no value.| 136 137**Example** 138 139 ```ts 140 import Base from '@ohos.base'; 141 import formBindingData from '@ohos.application.formBindingData'; 142 import formProvider from '@ohos.application.formProvider'; 143 144 let formId: string = '12400633174999288'; 145 let param: Record<string, string> = { 146 'temperature': '22c', 147 'time': '22:00' 148 } 149 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 150 formProvider.updateForm(formId, obj).then(() => { 151 console.log('formProvider updateForm success'); 152 }).catch((error: Base.BusinessError) => { 153 console.error(`formProvider updateForm, error: ${JSON.stringify(error)}`); 154 }); 155 ``` 156