Forms

.Components. Forms

new Forms(context, options)

Source:
Tutorials:
Represents a component that provides both UI and programmatic interaction with PMA.core forms and data.
Parameters:
Name Type Description
context PMA.UI.Components.Context
options Object Reserved for future use

Members

(static, readonly) FieldType :number

Source:
Properties:
Name Type Description
Text number Simple text (input)
Paragraph number Simple paragraph (label)
ListBox number Dropdown
CheckBox number Checkbox list
RadioButton number Radio button list
Integer number Integer input
Double number Decimal input
DateTime number Datetime input
Percentage number Percentage input
Label number Section separator - label
HyperLink number HyperLink
Available form field types
Type:
  • number

Methods

displayForm(serverUrl, formId, element, dataOptionsopt, successopt, failureopt)

Source:
Renders a form and optionally loads the available user submitted data
Parameters:
Name Type Attributes Description
serverUrl string
formId Number
element string | HTMLElement The element that hosts the form. It can be either a valid CSS selector or an HTMLElement instance.
dataOptions Object <optional>
Supplied only when it is desired to load form submitted data as well
Properties
Name Type Attributes Default Description
path string The path to load form submitted data for
currentUserOnly boolean <optional>
false True to load only the current user's data. The user is determined by the server's URL and the authentication providers available in the context.
dataFilter string | PMA.UI.Components.Forms~filterDataCallback <optional>
"" Optional parameter to filter data results with. If the parameter is a string it is considered a username and data from this user are kept. This is useful when a particular user's data is desired, but not the currently logged on one's. If a callback function is provided it should return the filtered data
btnContainerClass string <optional>
CSS class to assign the to element that contains the save and reset buttons
btnResetClass string <optional>
CSS class to assign the reset button
btnSaveClass string <optional>
CSS class to assign the save button
fieldCb PMA.UI.Components.Forms~renderFieldCallback <optional>
Called when rendering each field.
fieldContainerClass string <optional>
CSS class to assign the to element that contains field controls
fieldValidationClass string <optional>
CSS class to assign to error labels that are displayed upon validating the form
formClass string <optional>
CSS class to assign to the rendered form element
inputClass string <optional>
CSS class to assign the to input elements
readOnly boolean <optional>
false True to render the form in read only mode
editButton boolean <optional>
false True to render an edit button next to the form's name. Only applicable in read only mode
validationClass string <optional>
CSS class to assign to generic validation messages (e.g. "The form could not be saved")
success function <optional>
failure function <optional>

getEnabled() → {boolean}

Source:
Gets the state of the currently rendered form
Returns:
Type
boolean

getForm(serverUrl, formId, dataOptionsopt, successopt, failureopt)

Source:
Loads a form definition and optionally the available submitted data
Parameters:
Name Type Attributes Description
serverUrl String
formId Number
dataOptions Object <optional>
Used when it is desired to load submitted data as well
Properties
Name Type Attributes Default Description
path string The path to load form submitted data for
currentUserOnly boolean <optional>
false True to load only the current user's data. The user is determined by the server's URL and the authentication providers available in the context.
dataFilter string | PMA.UI.Components.Forms~filterDataCallback <optional>
"" Optional parameter to filter data results with. If the parameter is a string it is considered a username and data from this user are kept. This is useful when a particular user's data is desired, but not the currently logged on one's. If a callback function is provided it should return the filtered data
success PMA.UI.Components.Forms~getFormCallback <optional>
failure function <optional>

getForms(serverUrl, success, failureopt)

Source:
Loads all the available form definitions from a PMA.core server
Parameters:
Name Type Attributes Description
serverUrl String The PMA.core server URL
success PMA.UI.Components.Forms~getFormsCallback Called upon successful completion of the data request.
failure function <optional>

hasChanges() → {boolean}

Source:
Checks if the currently loaded form has any changes that have not been saved yet.
Returns:
Type
boolean

listen(eventName, callback)

Source:
Attaches an event listener
Parameters:
Name Type Description
eventName PMA.UI.Components.Events The name of the event to listen to
callback function The function to call when the event occurs

renderForm(element, form, dataOptionsopt, dataopt, successopt, failureopt)

Source:
Renders a form and optionally loads the available user submitted data without loading from the server
Parameters:
Name Type Attributes Description
element string | HTMLElement The element that hosts the form. It can be either a valid CSS selector or an HTMLElement instance.
form Object The form definition object
dataOptions Object <optional>
Supplied only when it is desired to load form submitted data as well
Properties
Name Type Attributes Default Description
path string The path to load form submitted data for
currentUserOnly boolean <optional>
false True to load only the current user's data. The user is determined by the server's URL and the authentication providers available in the context.
dataFilter string | PMA.UI.Components.Forms~filterDataCallback <optional>
"" Optional parameter to filter data results with. If the parameter is a string it is considered a username and data from this user are kept. This is useful when a particular user's data is desired, but not the currently logged on one's. If a callback function is provided it should return the filtered data
btnContainerClass string <optional>
CSS class to assign the to element that contains the save and reset buttons
btnResetClass string <optional>
CSS class to assign the reset button
btnSaveClass string <optional>
CSS class to assign the save button
fieldCb PMA.UI.Components.Forms~renderFieldCallback <optional>
Called when rendering each field.
fieldContainerClass string <optional>
CSS class to assign the to element that contains field controls
fieldValidationClass string <optional>
CSS class to assign to error labels that are displayed upon validating the form
formClass string <optional>
CSS class to assign to the rendered form element
inputClass string <optional>
CSS class to assign the to input elements
readOnly boolean <optional>
false True to render the form in read only mode
editButton boolean <optional>
false True to render an edit button next to the form's name. Only applicable in read only mode
validationClass string <optional>
CSS class to assign to generic validation messages (e.g. "The form could not be saved")
data Object <optional>
The data to load to the form displayed
success function <optional>
failure function <optional>

renderReadOnlyField(field, record, cssClass) → {string}

Source:
Renders a form field in read-only form
Parameters:
Name Type Description
field Object A PMA.core form field structure
record Object A PMA.core form field value structure
cssClass string Extra CSS class to add to the container element
Returns:
The HTML output
Type
string

reset()

Source:
Resets the currently loaded form to it's initial state

saveForm(successopt, failureopt)

Source:
Saves the currently rendered form to PMA.core
Parameters:
Name Type Attributes Description
success function <optional>
failure function <optional>
Fires:

setEnabled(enabled)

Source:
Enables or disables the currently rendered form
Parameters:
Name Type Description
enabled boolean

Type Definitions

filterDataCallback(dataopt) → {Object}

Source:
A callback to filter the data retrieved from the server
Parameters:
Name Type Attributes Description
data Object <optional>
The retrieved form data
Returns:
The filtered data
Type
Object

getFormCallback(form, dataopt)

Source:
Passes a form definition and optionally form data back to the caller
Parameters:
Name Type Attributes Description
form Object The requested form definition
data Object <optional>
The submitted form data

getFormsCallback(forms)

Source:
Passes form definitions back to the caller
Parameters:
Name Type Description
forms Array.<Object> Form definition objects fetched from PMA.core

renderFieldCallback(form, field, recordopt) → {boolean}

Source:
Called while rendering each field. This function gives the opportunity to the caller to make modifications per element, or return false to prevent rendering of specific fields.
Parameters:
Name Type Attributes Description
form Object The definition of the form that is being rendered
field Object The definition of the field that is being rendered
Properties
Name Type Description
fieldGroupClass Object The CSS class to assign to the fields group element
fieldContainerClass Object The CSS class to assign to the field's container
record Object <optional>
The data that will be displayed by the field. Can be null if no data is available or loaded.
Returns:
True to render this field, otherwise false
Type
boolean