webmcp
annotate framework/env/ui/field/file.lua @ 66:afed1ab1477f
Bugfix regarding compatibility with Lua 5.2:
#if instead of #ifdef in webmcp_accelerator.c
#if instead of #ifdef in webmcp_accelerator.c
| author | jbe |
|---|---|
| date | Tue Apr 17 15:38:05 2012 +0200 (2012-04-17) |
| parents | 36ebcae1cde3 |
| children |
| rev | line source |
|---|---|
| jbe@56 | 1 --[[-- |
| jbe@56 | 2 ui.field.file{ |
| jbe@56 | 3 ... -- generic ui.field.* arguments, as described for ui.autofield{...} |
| jbe@56 | 4 } |
| jbe@56 | 5 |
| jbe@56 | 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{...}. |
| jbe@56 | 7 |
| jbe@56 | 8 --]]-- |
| jbe@56 | 9 |
| jbe@56 | 10 function ui.field.file(args) |
| jbe@56 | 11 ui.form_element(args, nil, function(args) |
| jbe@56 | 12 if args.readonly then |
| jbe@56 | 13 -- nothing |
| jbe@56 | 14 else |
| jbe@56 | 15 if not slot.get_state_table().form_file_upload then |
| jbe@56 | 16 error('Parameter "file_upload" of ui.form{...} must be set to true to allow file uploads.') |
| jbe@56 | 17 end |
| jbe@56 | 18 local attr = table.new(args.attr) |
| jbe@56 | 19 attr.type = "file" |
| jbe@56 | 20 attr.name = args.html_name |
| jbe@56 | 21 ui.tag{ tag = "input", attr = attr } |
| jbe@56 | 22 end |
| jbe@56 | 23 end) |
| jbe@56 | 24 end |