[luci] Setting form values based on selected option in combo box

Jo-Philipp Wich xm at subsignal.org
Sat Nov 1 11:23:36 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

> I have a need to override two form values when a user selects any
> of a specific subset of combobox options, I tried implementing this
> in the validate function for the combo box but this seems to set
> the values in the form, but these aren’t written to the UCI file
> unless you hit save and apply twice.

Override the .write() callback of the select with something like that:

o.write = function(self, cfg, val)
  if val == "foo" then
    self.map:set(cfg, "option1", "foo")
    self.map:set(cfg, "option2", "bar")
  end
  return Value.write(self, cfg, val)
end


~ Jow


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlRUtKgACgkQdputYINPTPPP4ACfaBhLgQ+R36QRVi36MhI/Nqme
UDEAn0kB5GiLQQBNB8cUwnBRNX4IOAiA
=322b
-----END PGP SIGNATURE-----


More information about the luci mailing list