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