Instantiate a file upload widget.
| Name | Type | Default | Description |
|---|---|---|---|
value |
string | Array.<string> | null |
optional
The initial input value. |
options |
LuCI.ui.DynamicList.InitOptions |
optional
Object describing the widget specific options to initialize the file upload control. |
Extends
Methods
-
Returns the current validation error
Returns:
Type Description string The validation error at this time -
Read the current value of the input widget.
Returns:
Type Description string | Array.<string> | null The current value of the input element. For simple inputs like text fields or selects, the return value type will be a - possibly empty - string. Complex widgets such as DynamicListinstances may result in an array of strings ornullfor unset values. -
Check whether the input value was altered by the user.
Returns:
Type Description boolean Returns trueif the input value has been altered by the user orfalseif it is unchanged. Note that if the user modifies the initial value and changes it back to the original state, it is still reported as changed. -
Check whether the current input value is valid.
Returns:
Type Description boolean Returns trueif the current input value is valid orfalseif it does not meet the validation constraints. -
Dispatch a custom (synthetic) event in response to received events.
Sets up event handlers on the given target DOM node for the given event names that dispatch a custom event of the given type to the widget root DOM node.
The primary purpose of this function is to set up a series of custom uniform standard events such as
widget-update,validation-success,validation-failureetc. which are triggered by various different widget specific native DOM events.Name Type Description targetNodeNode Specifies the DOM node on which the native event listeners should be registered.
syneventstring The name of the custom event to dispatch to the widget root DOM node.
eventsArray.<string> The native DOM events for which event handlers should be registered.
-
Render the widget, set up event listeners and return resulting markup.
Returns:
Type Description Node Returns a DOM Node or DocumentFragment containing the rendered widget markup. -
Set up listeners for native DOM events that may change the widget value.
Sets up event handlers on the given target DOM node for the given event names which may cause the input value to change completely, such as
changeevents in a select menu. In contrast to update events, such change events will not trigger input value validation but they may cause field dependencies to get re-evaluated and will mark the input widget as dirty.Name Type Description targetNodeNode Specifies the DOM node on which the event listeners should be registered.
eventsstring repeatable The DOM events for which event handlers should be registered.
-
Set the current placeholder value of the input widget.
Name Type Description valuestring | Array.<string> | null The placeholder to set for the input element. Only applicable to text inputs, not to radio buttons, selects or similar.
-
Set up listeners for native DOM events that may update the widget value.
Sets up event handlers on the given target DOM node for the given event names which may cause the input value to update, such as
keyuporonclickevents. In contrast to change events, such update events will trigger input value validation.Name Type Description targetNodeNode Specifies the DOM node on which the event listeners should be registered.
eventsstring repeatable The DOM events for which event handlers should be registered.
-
Set the current value of the input widget.
Name Type Description valuestring | Array.<string> | null The value to set the input element to. For simple inputs like text fields or selects, the value should be a - possibly empty - string. Complex widgets such as
DynamicListinstances may accept string array ornullvalues. -
Force validation of the current input value.
Usually input validation is automatically triggered by various DOM events bound to the input widget. In some cases it is required though to manually trigger validation runs, e.g. when programmatically altering values.
Type Definitions
-
LuCI.ui.FileUpload.InitOptions
-
In addition to the
AbstractElement.InitOptionsthe following properties are recognized:Properties:
Name Type Argument Default Description browserboolean <optional>
false Use a file browser mode.
show_hiddenboolean <optional>
false Specifies whether hidden files should be displayed when browsing remote files. Note that this is not a security feature, hidden files are always present in the remote file listings received, this option merely controls whether they're displayed or not.
enable_uploadboolean <optional>
true Specifies whether the widget allows the user to upload files. If set to
false, only existing files may be selected. Note that this is not a security feature. Whether file upload requests are accepted remotely depends on the ACL setup for the current session. This option merely controls whether the upload controls are rendered or not.enable_removeboolean <optional>
true Specifies whether the widget allows the user to delete remove files. If set to
false, existing files may not be removed. Note that this is not a security feature. Whether file delete requests are accepted remotely depends on the ACL setup for the current session. This option merely controls whether the file remove controls are rendered or not.enable_downloadboolean <optional>
false Specifies whether the widget allows the user to download files.
root_directorystring <optional>
/etc/luci-uploads Specifies the remote directory the upload and file browsing actions take place in. Browsing to directories outside the root directory is prevented by the widget. Note that this is not a security feature. Whether remote directories are browsable or not solely depends on the ACL setup for the current session.