Performs an AJAX request to a database query created in the FORMCYCLE backend configuration interface. If the
query contains any placeholders (question marks ?
), exactly that number of parameters needs to be given or
the query fails.
// Callback when the query succeeded
function successFunc(data) {
// Do something with the returned data in JSON format
console.log(data);
if ( data.result.length > 0) $('[name=tfName]').val(data.result[0].name);
}
// Callback when the query failed
function errorFunc(jqXHR, textStatus, errorThrown) {
// Handle error
console.error(errorThrown);
}
function getData(paramID, paramMail) {
$.xutil.getDataQuery('SampleDbQueryName', [paramID, paramMail],
successFunc, errorFunc);
}
// Run database query with parameter values taken from form fields
getData($('[name=tfId]').val(), $('[name=tfMail]').val());
Name of the database query, as set in the FORMCYCLE backend configuration interface.
Optional parameters passed to the database query.
Callback called when the database query succeeds.
Callback called when the database query fails.
Retrieves the value of the URL parameter for the given name. Returns the default if no such parameter exists.
If a parameter name occurs multiple times, all values are returned, separated with a comma (,
).
If the URL is as follows:
https://formcloud.de/formcycle/form/provide/9999?name=James&preview&mode=&name=John
Then this function returns:
$.xutil.getFormParam("name") // => "James,John"
$.xutil.getFormParam("preview"); // => undefined
$.xutil.getFormParam("mode"); // => undefined
$.xutil.getFormParam("owner", "anonymous"); // => "anonymous"
Name of the URL parameter to retrieve.
Default value in case the URL parameter is not set.
The value of the given parameter name, or the default value if no such parameter exists.
Finds a FORM-specific URL of a certain type. If you need to access a FORMCYCLE resource, use this function as the URLs may change in future versions.
The following types of URLs are available:
/formcycle
.dataquery_db
instead.// This returns "/formcycle/datenquellecsv/"
$.xutil.getFormUrl("datasource_csv", undefined);
Type of the form URL to be retrieved.
Default value to be returned when no URL was found.
The form URL of the given type. If no such type exists, the given default value.
Performs an AJAX request to an LDAP query created in the FORMCYCLE backend configuration interface. If the
query contains any placeholders (question marks ?
), exactly that number of parameters needs to be given or
the query fails.
// Callback when the query succeeded
function successFunc(data) {
// Do something with the returned data in JSON format
console.log(data);
if ( data.result.length > 0) $('[name=tfName]').val(data.result[0].name);
}
// Callback when the query failed
function errorFunc(jqXHR, textStatus, errorThrown) {
// Handle error
console.error(errorThrown);
}
function getData(paramID, paramMail) {
$.xutil.getDataQuery('SampleDbQueryName', [paramID, paramMail],
successFunc, errorFunc);
}
// Run LDAP query with parameter values taken from form fields
getData($('[name=tfId]').val(), $('[name=tfMail]').val());
Name of the LDAP query, as set in the FORMCYCLE backend configuration interface.
Optional parameters passed to the LDAP query.
Callback called when the LDAP query succeeds.
Callback called when the LDAP query fails.
Helper function to check the current state of the form. States can be created and managed in the workflow configuration.
// When the form is opened for the first time (no state set), set
// the default value for the form element "tfMail".
if ($.xutil.isStatus(undefined)) {
$("[name='tfMail']").val("default@mail.com");
}
// Check for a certain state
var isArchived = $.xutil.isStatus("Archived");
Name of the state to check against the current state. You may pass undefined
to check
whether no state is set, ie. whether the form has not yet been submitted.
true
iff the current state of the form is the same as the given state, false
otherwise.
Helper function to run code when the form is currently in a given state. States can be created in the workflow configuration.
// When the form is opened for the first time (no state set),
// set the default value for the form element "tfMail"
$.xutil.onStatus(undefined, function() {
$("[name='tfMail']").val("default@mail.com");
});
$.xutil.onStatus('Archiv', function() {
// Do something when form is archived
});
Name of the state to check against the current state. You may pass undefined
to check
whether no state is set, ie. whether the form has not yet been submitted.
Function that is executed immediately (synchronous to the caller) in case the current state of the form matches the given state.
Helper function to run code when the form has got no state currently, ie. when it has not been submitted yet. States can be created in the workflow configuration.
// When the form is opened for the first time (no state set), set
// the default value for the form element tfMail.
$.xutil.onStatus(function() {
$("[name='tfMail']").val("default@mail.com");
});
Function that is executed immediately (synchronous to the caller) in case the current state of the form matches the given state.
A function that is called when the form is submitted. The default implementation simply returns true, so you
can override this function without calling the original function. When you would like to cancel the
submission of the form, return false
from this method.
$.xutil.onsubmit = function(isFormValid) {
// Custom code to be run on submission.
// ...
// Custom logic to check whether the form submission should be cancelled.
return isFormValid;
};
Whether the form is currently valid (eg. if all required fields have been filled out etc.)
true
to proceed with form submission, false
or undefined
to prevent the form's submission.
This object contains FORMCYCLE specific utility functions.