Form UDR

The Form UDR is used to create a form that includes other components where you can enter data to be sent to workflow.

Example of a simple form with one TextField and one Button

You can use the following APL code to create a form as shown above:

//Create the Form UDR Form searchform = udrCreate(Form); searchform.method = searchform.METHOD_POST; //Create the textfield to be included in the form. TextField searchText = udrCreate(TextField); searchText.id = "search"; //Must include name otherwise the data can not be sent to workflow searchText.name = "search"; searchText.placeholder = "Filter Results"; //Create the send button Button searchButton = udrCreate(Button); searchButton.buttonType = searchButton.SUBMIT; searchButton.text = "Search"; //Add the components to the form searchform.components = listCreate(ComponentUDR, searchText, searchButton);

Another example of a form that uses a grid to place the components.

Example of a form using grid

The APL code to produce the above example is this:

// Create text fields TextField userTextField = udrCreate(TextField); userTextField.name = "username"; userTextField.label = "Create a username"; TextField aliasTextField = udrCreate(TextField); aliasTextField.name = "alias"; aliasTextField.label = "Create an alias"; // Create a radio button group RadioButtonGroup radioButton = udrCreate(RadioButtonGroup); radioButton.name = "radioButton"; radioButton.label = "Select a color"; // Create a ordered map to control the order of the radio button radioButton.buttons = mapCreateOrdered(string, string); mapSet(radioButton.buttons, "Red", "red"); mapSet(radioButton.buttons, "Blue", "blue"); mapSet(radioButton.buttons, "Green", "green"); // Create integer fields IntegerField portIntegerField = udrCreate(IntegerField); portIntegerField.label = "Port"; portIntegerField.name = "port"; IntegerField timeoutIntegerField = udrCreate(IntegerField); timeoutIntegerField.label = "Timeout"; timeoutIntegerField.name = "timeout"; // Create a dropdown DropDown dropdown = udrCreate(DropDown); dropdown.name = "dropdown"; dropdown.label = "Dropdown"; dropdown.items = mapCreateOrdered(string, string); mapSet(dropdown.items, "Select an item", ""); mapSet(dropdown.items, "First Value", "first"); mapSet(dropdown.items, "Second Value", "second"); // Create a button to be used as the submit button in the form Button formSubmitButton = udrCreate(Button); formSubmitButton.text = "Submit"; formSubmitButton.buttonType = formSubmitButton.SUBMIT; // Create a grid to be used in the form Grid formGrid = udrCreate(Grid); formGrid.rows = listCreate(GridRow); // Add the columns to a row, and then insert that row into the formGrid's rows. // To simplify the creation of columns and rows, they have been moved to helper functions. listAdd(formGrid.rows, getRow([getColumn(userTextField, 6), getColumn(aliasTextField, 6)])); listAdd(formGrid.rows, getRow([getColumn(radioButton, 0)])); listAdd(formGrid.rows, getRow([getColumn(portIntegerField, 6), getColumn(timeoutIntegerField, 6)])); listAdd(formGrid.rows, getRow([getColumn(dropdown, 0)])); listAdd(formGrid.rows, getRow([getColumn(formSubmitButton, 0)])); // Create the form UDR Form form = udrCreate(Form); form.method = form.METHOD_POST; // Add the grid, which was created for the form and holds the components, as a component of the form. form.components = listCreate(ComponentUDR, formGrid);
// Helper functions for column and row GridColumn getColumn(ComponentUDR comp, int width){ GridColumn col = udrCreate(GridColumn); if(width > 0){ col.width = width; } col.components = listCreate(ComponentUDR, comp); return col; } GridRow getRow(list<GridColumn> columns){ GridRow row = udrCreate(GridRow); row.columns = listCreate(GridColumn); for (GridColumn column: columns) { listAdd(row.columns, column); } return row; }

The following fields are included in the Form UDR:

Field

Description

Field

Description

action (string)

This field may contain a string that specifies where to send the form data when a form is submitted.
Possible values:

attributes (map<string,string>)

This field may contain extra attributes to be added.

components (list<ComponentUDR>)

This field may contain a list of child components, the components that will produce the form data. They can be added direct in the list or inside a Grid UDR and then the Grid UDR is added here.

cssClasses (list<string>)

This field may contain a list of extra values added to class attribute. This is typically used to style the component. Please read more on Bootstrap.

encoding (string)

This field may contain may a string for encoding. Some constants is added to help:
URL_ENCODED, TEXT_PLAIN, MULTIPART
Default is URL_ENCODED.

id (string)

This field may contain the id of the component

method (int)

This field may contain method used to submit the form. Possible values are:
METHOD_GET, METHOD_POST.
Default is METHOD_GET.

name (string)

This field may contain the name of the component