Software /
code /
prosody
Comparison
util/dataforms.lua @ 7446:0db72fac2faa
util.dataforms: Fix including default value for list-single when given as field.value[].default
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 May 2016 15:57:03 +0200 |
parent | 7442:156c95bfed0b |
child | 8255:d70d4c1ac17a |
comparison
equal
deleted
inserted
replaced
7445:6d2038147d3d | 7446:0db72fac2faa |
---|---|
70 elseif field_type == "list-single" then | 70 elseif field_type == "list-single" then |
71 local has_default = false; | 71 local has_default = false; |
72 for _, val in ipairs(field.options or value) do | 72 for _, val in ipairs(field.options or value) do |
73 if type(val) == "table" then | 73 if type(val) == "table" then |
74 form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up(); | 74 form:tag("option", { label = val.label }):tag("value"):text(val.value):up():up(); |
75 if value == val.value or field.options and val.default and (not has_default) then | 75 if value == val.value or val.default and (not has_default) then |
76 form:tag("value"):text(val.value):up(); | 76 form:tag("value"):text(val.value):up(); |
77 has_default = true; | 77 has_default = true; |
78 end | 78 end |
79 else | 79 else |
80 form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up(); | 80 form:tag("option", { label= val }):tag("value"):text(tostring(val)):up():up(); |