Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-compat: CBI skip fields that do not satisfy depends #7463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jjm2473
Copy link
Contributor

@jjm2473 jjm2473 commented Dec 10, 2024

If depends is not satisfied, the fvalue will be nil.

@jow-

  • This PR is not from my main or master branch πŸ’©, but a separate branch βœ…
  • Each commit has a valid βœ’οΈ Signed-off-by: <my@email.address> row (via git commit --signoff)
  • Each commit and PR title has a valid πŸ“ <package name>: title first line subject for packages
  • Incremented πŸ†™ any PKG_VERSION in the Makefile
  • Tested on: (aarch64, openwrt 22.03, chrome) βœ…
  • ( Preferred ) Mention: @ the original code author for feedback
  • ( Preferred ) Screenshot or mp4 of changes:
  • Description: (describe the changes proposed in this PR)

A simple test code (model/cbi/abc.lua):

local m, s, o

m = Map("floatip", translate("FloatingGateway"))

s=m:section(NamedSection, "main", translate("Global settings"))
s.anonymous=true

o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false

o = s:option(ListValue, "role", translate("Node Role"))
o.rmempty = false
o.widget = "select"
o:value("main", translate("Preempt Node"))
o:value("fallback", translate("Fallback Node"))

o = s:option(Value, "set_ip", translate("Floating Gateway IP"))
o.rmempty = false
o.datatype = "or(ip4addr,cidr4)"

o = s:option(Value, "check_ip", translate("Preempt Node IP"))
o.rmempty = false
o.datatype = "ip4addr"
o:depends("role", "fallback")

return m

Without this patch, when "role" changes from "fallback" to "main", save will failed with 'missing' error (One or more required fields have no value!).

If depends is not satisfied, the fvalue will be nil.

Signed-off-by: Liangbin Lian <jjm2473@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant