Methods
(static) addClassName(fields, disabled)
Add style class to form item. This is opposite of removeClassName function
Example
var formData = {name: 'XYZ', age: 28, country: 'England'}
.custom-style {
background: red;
}
var className = 'custom-style'
var fields = ['name', 'age']
this.addClassName(fields, className)
// Now the 'background color' of Name and Age fields are 'red' in color
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | |
disabled |
Boolean | true/false |
(static) database(name)
Access database for List(get all records), Read (get a record), Update (update a record), Delete (delete a record). This is an Object of functions. Click Here
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Database name |
(static) disabled(fields, disabled)
Dynamically set whether a form field is disabled
Examples
// Disable name and age fields from user interaction
var formData = {name: 'XYZ', age: 28, country: 'England'}
var fields = ['name', 'age']
this.disabled(fields, true)
// 'name' and 'age' fields in the form are unclickable and unchangeable
// Enable name and age fields for user interaction
this.disabled(fields, false)
// 'name' and 'age' fields in the form are now enabled for user interaction
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | |
disabled |
Boolean | true/false |
(static) display(fields)
Display/Show Fields. This is opposite of hide function
Example
var formData = {name: 'XYZ', age: 28, country: 'England'}
var fields = ['name', 'age']
this.display(fields)
// Displays only 'name' and 'age' fields in the form
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array |
(static) getComponent(name) → {Object}
'dialog' is the ID field in the 'Component Attribute' tab
Example
var myDialog = this.getComponent('myDialog')
// myDialog component object
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The component name |
Returns:
- Component Object
- Type
- Object
(static) getData(isValidateopt) → {Promise.<Object>}
To get form data
Examples
Validate form data Object by default
try {
var data = await this.getData()
// if success returns validated data as an object {name: 'XYZ'}
} catch (err) {
// returns err message
}
}
var data = await this.getData(false)
// data contains {name: 'XYZ'}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
isValidate |
Boolean |
<optional> |
true
|
Returns:
All of the form data
- Type
- Promise.<Object>
(static) getValue(fieldName)
Get A Value From An Object
Example
var myData = {name: 'Joe Blogs', age: 30};
this.getValue('name')
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
string | Field Name |
Returns:
'Joe Blogs'
(static) getValues() → {Object}
Get the values of all fields in the dialg
Example
var data = this.getValues()
console.log(data) // {name: 'XYZ', age: 28, country: 'England'}
Returns:
- Type
- Object
(static) hide(fields)
Hide Fields. This is opposite of display function
Example
var formData = {name: 'XYZ', age: 28, country: 'England'}
var fields = ['name', 'age']
this.hide(fields)
// Displays only 'country' field in the form
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | ['name', 'age'] |
(static) refresh()
refresh the form, when the form data changes, you need to call this method for re-render
Example
this.refresh()
(static) refreshFieldDataSource(field, args)
Refresh the datasource data bound to the form field
Example
Get Provider Rate Cards When Provider Field Is selected
var providerId = 1789
var providerRateCards = this.refreshFieldDataSource('card', {id: providerId})
Parameters:
Name | Type | Description |
---|---|---|
field |
String | Datasource name |
args |
Object | key-value pair |
(static) removeClassName(fields, disabled)
Remove form item style class. This is opposite of addClassName function
Example
var formData = {name: 'XYZ', age: 28, country: 'England'}
.custom-style {
background: red;
}
var className = 'custom-style'
var fields = ['name', 'age']
this.removeClassName(fields, className)
// Now the 'background color' of Name and Age fields are not 'red' in color
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | |
disabled |
Boolean | true/false |
(static) reset()
Reset Form Fields Data
Example
this.reset()
(static) scriptForge(name, data, fn, args) → {Promise.<Boolean>}
Access scriptForge
Parameters:
Name | Type | Description |
---|---|---|
name |
string | script forge name |
data |
Object | |
fn |
string | function name |
args |
Object | arguments |
Returns:
Validation Success or Failure
- Type
- Promise.<Boolean>
(static) sendRequest(name, args, extendOptions) → {Promise.<Boolean>}
send a request to GET, POST, PUT, DELETE
Example
try {
var res = await this.sendRequest('customer')
// if success returns response and data as an array [{id: 1, name: 'XYZ'}, {id: 2, name: 'JOE'}]
} catch (err) {
// returns err message
}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
args |
Object | arguments, datasource parameters |
extendOptions |
Object | extendOptions |
Returns:
Validation Success or Failure
- Type
- Promise.<Boolean>
(static) setData(Value)
Set Data
Example
var myData = {name: 'Joe Blogs', age: 30};
this.setData(myData);
Parameters:
Name | Type | Description |
---|---|---|
Value |
Object |
(static) setOptionData(fields, newData)
Dynamic option data assignment
Example
// pending
var formData = {name: '', age: 28, country: 'England'}
var field = ['name']
var newData = {}
this.setOptionData(fields, newData)
Ask Jon
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | |
newData |
Object | key-value pair |
(static) setOptions(fields, options)
Set Form Field Configuration Item
Example
// Make Name field: Have a default value, a placeholder and as required
var formData = {name: '', age: 28, country: 'England'}
var field = ['name']
var options = {defaultValue: 'Default Name', placeholder: 'Name', required: true}
this.setOptions(fields, options)
Parameters:
Name | Type | Description |
---|---|---|
fields |
Array | |
options |
Object | key-value pair |
(static) setRules(field, rules)
Set Form Field Validation Rules
Examples
// Make Name as a required field
var field = 'name'
var rules = [
{ required: true, message: 'Name is requried' }
]
this.setRules(field, rules)
// Remove name as a required field
var field = 'name'
var rules = [
{ required: false }
]
this.setRules(field, rules)
Parameters:
Name | Type | Description |
---|---|---|
field |
string | |
rules |
Array | Array of Objects |
(static) validate(fieldsopt) → {Promise.<Boolean>}
Validates the form data or a key-value pair // Returns Both The Success And Failure Results
Examples
Validate Only A Set Of Array Of Fields
var formData = {name: '', age: 28, country: 'England'}
var fields = ['name', 'age']
this.validate(fields)
If No Array Of Fields, Validates The Entire Form
this.validate()
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fields |
Array |
<optional> |
[]
|
Returns:
Validation Success or Failure
- Type
- Promise.<Boolean>