I am not sure there is not a simpler way. But this way you'll get what you want.
a) Create a custom field to implement your logic. You can extend from any basic custom field types.
b) Simply set it manually to default to 0 (the attribute
default="0" is accepted in most form types). This will not set the value until the user actually saves the preferences; or you could preset the values in the script mentioned below.
c) Yes. it works for any extension type. Check the docs here.
Please take a moment to check the naming convention: the class name in the installer must be exact, otherwise it will simply not be invoked, and no error will be thrown to set you on the right path. In your
install.php methods i.e.
install, update, preflight, postflight, you can queue messages:
to know when code is working.
If my extension plugin xml name is "easyhttps":
becomes PlgSystemJsonloggerInstallerScript in the classname of the installer:
A plugin with an underscore in its name: "stripe_button"
Will keep it in the classname of the installer: PlgSystemStripe_buttonInstallerScript
Bonus: A plugin with an underscore and a dash in its name: "editors-xtd/stripe_xtd"
<extension version="2.5.0" type="plugin" group="editors-xtd" method="upgrade">
Will lose the dash in the classname of the installer: Plgeditorsxtdstripe_xtdInstallerScript
It is not too important: all the following work: