diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-12-03 23:20:18 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-12-03 23:30:12 +0200 |
commit | f8feba97a9ea3b1718f8c2a4a218f4a1a54711dd (patch) | |
tree | 1138ceb0a5afe67316cec5b5bc23e4f522870a86 | |
parent | d780c72ff1ffa4963a241d19778e2d7a58abe5bf (diff) | |
download | aconf-f8feba97a9ea3b1718f8c2a4a218f4a1a54711dd.tar.bz2 aconf-f8feba97a9ea3b1718f8c2a4a218f4a1a54711dd.tar.xz |
model: set default ui-value for object-type choices
-rw-r--r-- | acf2/model/field.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/acf2/model/field.lua b/acf2/model/field.lua index fe7fc07..c31e6be 100644 --- a/acf2/model/field.lua +++ b/acf2/model/field.lua @@ -61,9 +61,7 @@ function M.Field:init(params) if self.choice then self.choice = map( function(choice) - if type(choice) ~= 'table' then - choice = {choice, self:auto_ui_name(choice)} - end + if type(choice) ~= 'table' then choice = {choice} end for i, k in ipairs{'value', 'ui-value'} do if choice[i] then assert(not choice[k]) @@ -71,7 +69,9 @@ function M.Field:init(params) choice[i] = nil end end - return choice + return util.setdefaults( + choice, {['ui-value']=self:auto_ui_name(choice.value)} + ) end, self.choice ) |