From 367e73a610e687ae01a6987023683d3ea9eac805 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 1 Sep 2018 01:24:46 +0200 Subject: util.dataforms: Allow field names to be different from the 'var' attribute This should allow the usage of long prefixes and namespace-like names to be contained to the XML representation of the form, so that the code can use more convenient names. --- spec/util_dataforms_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec') diff --git a/spec/util_dataforms_spec.lua b/spec/util_dataforms_spec.lua index 863a3290..123b9f8a 100644 --- a/spec/util_dataforms_spec.lua +++ b/spec/util_dataforms_spec.lua @@ -386,5 +386,20 @@ describe("util.dataforms", function () assert.same(expect, data, "got back the same data"); end); end); + + describe("field 'var' property", function () + it("works as expected", function () + local f = dataforms.new { + { + var = "someprefix#the-field", + name = "the_field", + type = "text-single", + } + }; + local x = f:form({the_field = "hello"}); + assert.equal("someprefix#the-field", x:find"field@var"); + assert.equal("hello", x:find"field/value#"); + end); + end); end); -- cgit v1.2.3