* luci/libs/uvl: implement default value option for variable sections
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 7 Sep 2008 02:55:42 +0000 (02:55 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 7 Sep 2008 02:55:42 +0000 (02:55 +0000)
libs/uvl/luasrc/uvl.lua
libs/uvl/root/lib/uci/schema/meta/schema

index f40063c..089789a 100644 (file)
@@ -1119,7 +1119,7 @@ end
 --- Get the value of this option.
 -- @return     The associated configuration value
 function option.value(self)
 --- Get the value of this option.
 -- @return     The associated configuration value
 function option.value(self)
-       local v = self:config()
+       local v = self:config() or self:scheme('default')
        if v and self:scheme('multival') then
                v = luci.util.split( v, "%s+", nil, true )
        end
        if v and self:scheme('multival') then
                v = luci.util.split( v, "%s+", nil, true )
        end
index dd373f8..7f6981a 100644 (file)
@@ -267,6 +267,15 @@ config variable
        option datatype 'string'
        option required false
 
        option datatype 'string'
        option required false
 
+# Variable default value (schema.@variable.default)
+config variable
+       option name             'default'
+       option title    'Datatype of this variable'
+       option section  'schema.variable'
+       option type             'variable'
+       option datatype 'string'
+       option required false
+
 # Variable validators (schema.@variable.validator)
 config variable
        option name             'validator'
 # Variable validators (schema.@variable.validator)
 config variable
        option name             'validator'