webmcp

changeset 476:993fbee179ae

Added json sub attribute support for form element
author bsw
date Tue Jun 06 11:47:33 2017 +0200 (2017-06-06)
parents a2ff42a66212
children be5db15e2d9a
files framework/env/ui/form_element.lua
line diff
     1.1 --- a/framework/env/ui/form_element.lua	Tue Jun 06 11:46:44 2017 +0200
     1.2 +++ b/framework/env/ui/form_element.lua	Tue Jun 06 11:47:33 2017 +0200
     1.3 @@ -32,7 +32,19 @@
     1.4          args.record = slot_state.form_record
     1.5        end
     1.6        if args.record then
     1.7 -        args.value = args.record[args.name]
     1.8 +        local path = {}
     1.9 +        for match in string.gmatch(args.name, "[^%.]+") do
    1.10 +          path[#path+1] = match
    1.11 +        end
    1.12 +        local value = args.record
    1.13 +        for i, path_element in ipairs(path) do
    1.14 +          if type(value) == "table" then
    1.15 +            value = value[path_element]
    1.16 +          else
    1.17 +            value = nil
    1.18 +          end
    1.19 +        end
    1.20 +        args.value = value
    1.21        end
    1.22      else
    1.23        args.value = nihil.lower(args.value)

Impressum / About Us