An alternative would be to override the handleSave
(and/or handleSaveApply
depending on what behavior you need) function to add your own implementation which includes the fw_setenv
invocation, see How to create a LuCI form without new form.Map - #5 by dannil. Note that if you do this you also need to handle the UCI persisting yourself as well (if that's needed). You can take a look at for example how custom iptables commands in luci-app-firewall are handled.
Here's the link to the docs https://openwrt.github.io/luci/jsapi/LuCI.view.html#handleSave