From d674359cdefae70f3cc1fa6439c96c82b508b5e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sun, 10 Nov 2013 20:52:04 +0100
Subject: Sluift: Use 'value' instead of 'values' for multi-value fields

Change-Id: Ie8d6bd4b732dd57cd4dc5ba63a9f6f6148348b2a

diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp
index e44ca3e..9791bfa 100644
--- a/Sluift/ElementConvertors/FormConvertor.cpp
+++ b/Sluift/ElementConvertors/FormConvertor.cpp
@@ -92,7 +92,7 @@ namespace {
 		}
 
 		if (field->getType() == FormField::ListMultiType || field->getType() == FormField::JIDMultiType || field->getType() == FormField::TextMultiType) {
-			luaField["values"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
+			luaField["value"] = Lua::valueRef(Lua::Array(field->getValues().begin(), field->getValues().end()));
 		}
 		else if (field->getType() == FormField::BooleanType) {
 			luaField["value"] = Lua::boolRef(field->getBoolValue());
@@ -179,7 +179,7 @@ namespace {
 			result->setBoolValue(*value);
 		}
 		else {
-			lua_getfield(L, -1, "values");
+			lua_getfield(L, -1, "value");
 			if (lua_istable(L, -1)) {
 				for (lua_pushnil(L); lua_next(L, -2); ) {
 					if (lua_isstring(L, -1)) {
diff --git a/Sluift/Tests/FormTest.lua b/Sluift/Tests/FormTest.lua
index 7b6b4af..b2ec111 100644
--- a/Sluift/Tests/FormTest.lua
+++ b/Sluift/Tests/FormTest.lua
@@ -59,10 +59,10 @@ assert(public_field['required'] == true)
 -- Test multi field
 features_field = form['fields'][8]
 assert(features_field['name'] == 'features')
-assert(type(features_field['values']) == 'table')
-assert(#features_field['values'] == 2)
-assert(features_field['values'][1] == 'news')
-assert(features_field['values'][2] == 'search')
+assert(type(features_field['value']) == 'table')
+assert(#features_field['value'] == 2)
+assert(features_field['value'][1] == 'news')
+assert(features_field['value'][2] == 'search')
 
 -- Test shortcut index
 assert(form['features']['name'] == 'features')
-- 
cgit v0.10.2-6-g49f6