Folder, File

A folder or file selection for use with RPCs

To choose a file instead of a folder, the desired option has to contain "file": true. When the field type is file, the file is required and only the folder is passed, the validation will fail.

Specification

options

Available types:

Type
Specification

string

The URL of an RPC returning the list of folders or files.

object

A detailed configuration of the folder/file list.

Available parameters:

Parameter
Type
Specification

store

string

The URL of an RPC returning the list of folders or files.

ids

Boolean

If set to true , you can work with folder IDs. The GUI loads previously selected folders and their labels after reopening the form without having to call the RPC again.

showRoot

showRoot

Default: true. If set to false , top-level folders aren't prefixed with / and there's no option to choose the root /. When the type is file , the root selection is blocked automatically.

singleLevel

Boolean

Default: false. If set to true , only a single level of folders is available.

Examples

Result of RPC

To display the folder/file selector properly, the output from your RPC should contain only objects matching the following samples.

option

Available parameters:

Parameter
Type
Specification

label

string

The label to be displayed.

value

string

The value of an option that will be used in code.

file

Boolean

Boolean to determine if the option is a file or a folder.

{
    "label": "Documents and Settings",
    "value": "documentandsettings"
}

Folder selection

To make your folder selection work properly, you need to create a remote procedure that will return the corresponding folders. Each time a folder is selected, the RPC is called and the parameter path containing the whole path in the string is passed. You need to filter the folders inside this RPC.

File selection

The file selection is very similar to the folder selection, but files in your RPC result have to contain the "file": true property. Each time a file is selected, the RPC is called and the parameter path containing the whole path in the string is passed. You need to filter the folders and files inside this RPC.

Last updated