0500-contact-info.lua 953 B

123456789101112131415161718192021222324252627
  1. return function(form, uci)
  2. local site = require 'gluon.site_config'
  3. local owner = uci:get_first("gluon-node-info", "owner")
  4. local s = form:section(Section, nil, translate(
  5. 'Please provide your contact information here to '
  6. .. 'allow others to contact you. Note that '
  7. .. 'this information will be visible <em>publicly</em> '
  8. .. 'on the internet together with your node\'s coordinates.'
  9. ))
  10. local o = s:option(Value, "contact", translate("Contact info"), translate("e.g. E-mail or phone number"))
  11. o.default = uci:get("gluon-node-info", owner, "contact")
  12. o.optional = not ((site.config_mode or {}).owner or {}).obligatory
  13. -- without a minimal length, an empty string will be accepted even with "optional = false"
  14. o.datatype = "minlength(1)"
  15. function o:write(data)
  16. if data then
  17. uci:set("gluon-node-info", owner, "contact", data)
  18. else
  19. uci:delete("gluon-node-info", owner, "contact")
  20. end
  21. end
  22. return {'gluon-node-info'}
  23. end