villejuif / setting_form
setting_form helps to create a JSON file of parameters writen in PHP.
0.1.3
2025-01-25 18:13 UTC
Requires
- php: >=8.2
- components/font-awesome: ^6.4
- scssphp/scssphp: ^1.12.1
- tinymce/tinymce: ^7
- tweeb/tinymce-i18n: ^2
README
- License GNU Affero General Public License v3
- Presentation
- Screenshot
- Installation
Presentation
This library offers forms leading to the production of a JSON file containing the data entered in these forms. This can be useful to give a user the possibility via a browser to set up an application.
The forms themselves are configured in a JSON file.
Example
See Screenshot.
Config file
json/config.json describes forms
category
{
"CATEGORY_ID": {
"label": "Category label displayed as tab title",
"title": "Category title",
"comment": "Category comment",
"fields": {
...
- CATEGORY_ID and label are required
- CATEGORY_ID composed of upper letters
- comment can contain html tags
Options:
- multiple: authorize multiple records to create a list, with options:
- "min": min count of record
- "max": max count of record
- "default": default count of record
field list
...
"fields": {
"FIELD_ID": {
"label": "Field label",
"type": "text",
"default": "default value",
"css": "css class name",
"required": "true"
},
...
- FIELD_ID, label, type are required
- FIELD_ID composed of upper letters
- type can be :
- text
- password
- url
- date
- number
- range
- select
- list
- checkbox
- textarea
- textarea html
Options for all types
* required: true
* css: css class name
* disable: true
* readonly: true
* default: default value, type depends on field type
option for text type
- minlength
- maxlength
- placeholder
options for number and range type
- min
- max
- step
option for select type
- options: list of options :
- "label": "value"
- options: list of options :
Example:
...
"LIMITDISPLAY": {
"label": "Représentation des limites",
"comment": "Type de représentation des limites. En arc prend moins de surface. Dégradé est plus figuratif.",
"type": "select",
"default": "gradation",
"required": "true",
"options": {
"gradation": "dégradé",
"arc": "arc de couleur unie"
}
},
...
- option for list type
Same display as select type, but options refer to values of other multiple paramaters list
- list:
- base: category ID
- label: label field name in category base
- value: value field name in category base
- list:
Example with a hierarchical autoreference:
...
"ACTIONS": {
"label": "Actions",
"multiple": {
},
"fields": {
"LABEL": {
"label": "Action label",
"type": "text"
},
"ID": {
"label": "Id",
"type": "text",
"minlength": 2,
"maxlength": 8,
"required": "true",
"unique" : "unique"
},
"PARENT": {
"label": "Parent",
"type": "list",
"list": {
"base": "ACTIONS",
"label": "LABEL",
"value": "ID"
}
},
...
Other example with reference to another category
...
"ONECOLOGICALCEILING": {
"label": "Effect on ecological ceiling",
"title": "Effect on ecological ceiling",
"multiple": {
},
"fields": {
"ECOLOGICALCEILING": {
"label": "Ceiling concerned",
"type": "list",
"list": {
"base": "ECOLOGICALCEILING",
"label": "LABEL",
"value": "ID",
"unique" : "unique"
},
"required": "true"
},
"FORCE": {
"label": "Action force on ecological ceiling",
"type": "range",
"min": -100,
"max": 100,
"step": 1
}
}
},
...
reference to
...
"ECOLOGICALCEILING": {
"label": "Ecological ceilings",
"title": "Ecological ceilings",
"multiple": {
"min": 1,
"max": 20,
"default": 2
},
"fields": {
"LABEL": {
"label": "Intitulé de limite planétaire",
"type": "text",
"required": "true"
},
"ID": {
"label": "Id",
"type": "text",
"minlength": 2,
"maxlength": 8,
"required": "true",
"unique": "unique"
},
...