Skip to content
sam detweiler edited this page Dec 14, 2024 · 7 revisions

Welcome to the MMM-Config wiki!

this section will be for info on how to create custom form definitions for a module

the why

Wouldn't it be nice if all the users reporting problems were reporting actual user problems, 
not accidental typos, case mismatches (ApiKey vs apiKey or apikey) , or bad configuration parameters. 

wouldn't it be nice, if there are multiple choices for a parameter, just let them CHOOSE from the list 
numbers in number fields, arrays built correctly, quotes where they need to be, no missing or extra {}, 
or missing commas

wouldn't it be nice, if the process was the same for every module... however it was solved.

the how

create a form, text vs numeric fields, drop downs/selection lists, help, descriptions,

That is what MMM-Config does, using the [JSONFORM](https://github.com/jsonform/jsonform) library 

the file created for each module is called a schema file. it contains 3 sectionn
  • schema

    • describe the fields in your modules defaults:{} section, which are used in config.js
    • the description of the fields include
    • name
    • data type (string, number, int, array, object, boolean/true/false)
    • some constraints, list of choices (enum), ranges (min,max)
  • form
    the physical layout of the presentation to the user. fields, labels, descriptions, help, default values, and the order in which you think the user should experience configuring your module

    • for example
      1. apikey
      2. url
      3. update frequency
      4. UI options, colors, etc this section allows you to link the form sections to the fields described in the schema section you do NOT have to expose every schema field.
  • value
    the default values for the fields, when created new, true/false, numbers, strings, ...

the different approaches