1# FormProvider 2 3> **NOTE** 4> 5> 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. 6 7Provides APIs related to the widget provider. 8 9## Modules to Import 10 11``` 12import formProvider from '@ohos.application.formProvider'; 13``` 14 15## Required Permissions 16 17None. 18 19## setFormNextRefreshTime 20 21setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void; 22 23Sets the next refresh time for a widget. This API uses an asynchronous callback to return the result. 24 25**System capability** 26 27SystemCapability.Ability.Form 28 29**Parameters** 30 31| Name| Type | Mandatory| Description | 32| ------ | ------ | ---- | ------------------------------------- | 33| formId | string | Yes | ID of a widget. | 34| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 35| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 36 37**Example** 38 39 ```js 40 var formId = "12400633174999288"; 41 formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { 42 if (error.code) { 43 console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); 44 } 45 }); 46 ``` 47 48## setFormNextRefreshTime 49 50setFormNextRefreshTime(formId: string, minute: number): Promise<void>; 51 52Sets the next refresh time for a widget. This API uses a promise to return the result. 53 54**System capability** 55 56SystemCapability.Ability.Form 57 58**Parameters** 59 60| Name| Type | Mandatory| Description | 61| ------ | ------ | ---- | ------------------------------------- | 62| formId | string | Yes | ID of a widget. | 63| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | 64 65**Return value** 66 67| Type | Description | 68| ------------- | ---------------------------------- | 69| Promise\<void> |Promise used to return the result. | 70 71**Example** 72 73 ```js 74 var formId = "12400633174999288"; 75 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 76 console.log('formProvider setFormNextRefreshTime success'); 77 }).catch((error) => { 78 console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); 79 }); 80 ``` 81 82## updateForm 83 84updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<void>): void; 85 86Updates a widget. This API uses an asynchronous callback to return the result. 87 88**System capability** 89 90SystemCapability.Ability.Form 91 92**Parameters** 93 94| Name| Type | Mandatory| Description | 95| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 96| formId | string | Yes | ID of the widget to update.| 97| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | 98| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 99 100**Example** 101 102 ```js 103 import formBindingData from '@ohos.application.formBindingData'; 104 var formId = "12400633174999288"; 105 let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); 106 formProvider.updateForm(formId, obj, (error, data) => { 107 if (error.code) { 108 console.log('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** 120 121SystemCapability.Ability.Form 122 123**Parameters** 124 125| Name| Type | Mandatory| Description | 126| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 127| formId | string | Yes | ID of the widget to update.| 128| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | 129 130**Return value** 131 132| Type | Description | 133| -------------- | ----------------------------------- | 134| Promise\<void> | Promise used to return the result.| 135 136**Example** 137 138 ```js 139 import formBindingData from '@ohos.application.formBindingData'; 140 var formId = "12400633174999288"; 141 let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); 142 formProvider.updateForm(formId, obj).then(() => { 143 console.log('formProvider updateForm success'); 144 }).catch((error) => { 145 console.log('formProvider updateForm, error:' + JSON.stringify(error)); 146 }); 147 ``` 148