Propagate value from one CBI generated form for one uci config to other uci config files

Hi,

I have developed a custom app which accepts connections on a specific port. Configuration of the app is achieved through a simple CBI module which generates the LuCi page. A quick overview of the model is:

m = Map("custom_app")
s = m:section(NamedSection, "configuration")

p = s:option(Value, "app_port", "Port")

return m

I desire this app to be accessible via WAN for which I create a firewall rule:

config rule
        option name 'Allow-App-On-Wan'
        option src 'wan'
        option dest_port '4022'
        option proto 'tcp'
        option target 'ACCEPT'

So if I modify the port in LuCi the changes will only be reflected in the config of the custom app (/etc/config/custom_app) and I would have to manually change the firewall rule port.

My question is whether it is possible to modify the firewall rule port from the LuCi generated configuration page of the custom app so that when I change the configuration of the app via LuCi this gets reflected in the firewall config as well for that specific rule. How can one go about this? How can the value be captured from the form and propagated to the firewall config file?

Thanks in advance