0500-contact-info.lua 941 B

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