0

How do I add all name of a section in a ListValue in Luci using CBI?

I know how to do this for a list of options. For example if I have the config below.

config mysection 'foo'
    option key1 'abc'
    option key2 'def'

config mysection 'bar'
    option key1 '123'
    option key2 '456'

I can easily make a list of options key1 like so:

lv = s:option(ListValue, "xxx", "whatever");
m.uci:foreach("myconfig","mysection",
        function(i)
                lv:value(i.key1, i.key1)
        end)

This provides a drop down list with 'abc' and '123'

Now I need the same but using the name of the section. i.e. A list with 'foo' and 'bar'.

Noel
  • 3,749
  • 3
  • 22
  • 21

1 Answers1

0

This link gave me the answer.

lv = s:option(ListValue, "xxx", "whatever");
m.uci:foreach("myconfig","mysection",
        function(i)
                lv:value(i['.name'], i['.name'])
        end)

Interesting how editing a question helps you solving it.

Noel
  • 3,749
  • 3
  • 22
  • 21