Skip to content

form.addFileField

since 1.5.5

Add a file field to the current form.

form.addFileField(line, rect, path, fileType, getValue, setValue)

Parameters

Name Type Required Description
line FormLine yes the line where the field should be added
rect Rect yes the coordinates
path string yes the files directory
fileType string yes the files type: "txt" for text files, support .txt, "image" for image files, support .png, .jpg, .bmp, "lua" for lua script files, support .lua, .luac, "frk" for frk files, support .frk, "frsk" for frsk files, support .frsk, "bin" for binary files, support .bin, "audio" for audio files, support .wav, "video" for video files, support .mp4, "hex" for hex files, support .hex, "i18n" for translation files, support .i18n, "csv" for log files, support .csv, "md" for markdown files, support .md, followed by "+ext" to see the files with their extension
getValue function yes the function which will return the current file name
setValue function yes the function which will be called on file change

Returns

The new field

Examples

From the official Ethos documentation
form.addFileField(line, nil, "/audio/en/system", "audio", function() return filename end, function(newValue) filename = newValue end)

Used in

Real-world usage

Called 12 times across 1 open-source Ethos Lua project. A few short excerpts:
form.addFileField(ePanelLine, slots[1], "", "csv+ext", function ()
  return restoreFileName
end, function (newFile)
  restoreFileName = newFile
end)

lua/frsky/RB25_S/stab/basic/basic.lua:101