webmcp
view framework/env/ui/field/file.lua @ 386:e057f8d3f716
Callback of ui.list{...} receives index as second argument
| author | jbe | 
|---|---|
| date | Tue Dec 01 18:50:31 2015 +0100 (2015-12-01) | 
| parents | 36ebcae1cde3 | 
| children | 
 line source
     1 --[[--
     2 ui.field.file{
     3   ...                        -- generic ui.field.* arguments, as described for ui.autofield{...}
     4 }
     6 This function inserts a field for uploading a file in the active slot. For read-only forms this function does nothing. For description of the generic field helper arguments, see help for ui.autofield{...}.
     8 --]]--
    10 function ui.field.file(args)
    11   ui.form_element(args, nil, function(args)
    12     if args.readonly then
    13       -- nothing
    14     else
    15       if not slot.get_state_table().form_file_upload then
    16         error('Parameter "file_upload" of ui.form{...} must be set to true to allow file uploads.')
    17       end
    18       local attr = table.new(args.attr)
    19       attr.type  = "file"
    20       attr.name  = args.html_name
    21       ui.tag{ tag  = "input", attr = attr }
    22     end
    23   end)
    24 end
