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