Custom form configuration #268

Merged
tobru merged 34 commits from 165-form-configuration into main 2025-11-10 14:49:33 +00:00
Member

ref #165

  • Forms can be configured in the admin
  • Fields used in custom forms are validated
  • Hard-coded fields that are always included
  • Create instances with custom forms
  • Update instances with custom forms
  • Merge data from custom forms into full instance data
  • Expert mode toggle

Generators are not included yet, as the FQDN field handling requires some hardcoding anyways (and we want it to always be loaded for the expert form, regardless), so I think we should wait with the generators implementation until we need one.

ref #165 - [x] Forms can be configured in the admin - [x] Fields used in custom forms are validated - [x] Hard-coded fields that are always included - [x] Create instances with custom forms - [x] Update instances with custom forms - [x] Merge data from custom forms into full instance data - [x] Expert mode toggle Generators are not included yet, as the FQDN field handling requires some hardcoding anyways (and we want it to always be loaded for the expert form, regardless), so I think we should wait with the generators implementation until we need one.
rixx added 13 commits 2025-11-05 09:38:46 +00:00
rixx added 2 commits 2025-11-05 09:45:45 +00:00
Code style
All checks were successful
Tests / test (push) Successful in 28s
ca485978b9
tobru added the
UI/UX
label 2025-11-05 14:42:23 +00:00
Owner

Something is off with the migration:

❯ uv run src/manage.py migrate
CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0012_convert_user_info_to_array, 0013_add_form_config in core).
To fix them run 'python manage.py makemigrations --merge'

To unblock myself from testing, I executed (after creating a backup of my local db):

❯ uv run src/manage.py makemigrations --merge
Merging core
  Branch 0012_convert_user_info_to_array
    p Raw Python operation
  Branch 0013_add_form_config
    - Remove field advanced_fields from servicedefinition
    ~ Alter field name on organization
    + Add field form_config to servicedefinition

Merging will only work if the operations printed above do not conflict
with each other (working on different fields or models)
Should these migration branches be merged? [y/N] y

Created new merge migration /home/tobru/src/servala/portal/src/servala/core/migrations/0014_merge_20251105_1449.py
❯ uv run src/manage.py migrate
Operations to perform:
  Apply all migrations: account, admin, auditlog, auth, contenttypes, core, sessions, socialaccount
Running migrations:
  Applying core.0012_remove_advanced_fields... OK
  Applying core.0013_add_form_config... OK
  Applying core.0014_merge_20251105_1449... OK

After that, I could start with the testing.

Directly after this, navigating to e.g. /org/my-acme-7/services/redis/offering/1/ no form is shown anymore. I would have expected to see the same form as before because I didn't configure anything yet.

Trying to create a new form results in Invalid form configuration: None is not of type 'integer'. What am I doing wrong?

Screenshot_20251105_160504.png

Either allow the fields to be empty or add some defaults.

And when filling in all fields: You must include a 'name' field in the custom form config.

Screenshot_20251105_160830.png

EDIT: Got it, I must map to name, not metadata.name. I guess this is one of the fields that we need to hardcode.

Something is off with the migration: ``` ❯ uv run src/manage.py migrate CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0012_convert_user_info_to_array, 0013_add_form_config in core). To fix them run 'python manage.py makemigrations --merge' ``` To unblock myself from testing, I executed (after creating a backup of my local db): ``` ❯ uv run src/manage.py makemigrations --merge Merging core Branch 0012_convert_user_info_to_array p Raw Python operation Branch 0013_add_form_config - Remove field advanced_fields from servicedefinition ~ Alter field name on organization + Add field form_config to servicedefinition Merging will only work if the operations printed above do not conflict with each other (working on different fields or models) Should these migration branches be merged? [y/N] y Created new merge migration /home/tobru/src/servala/portal/src/servala/core/migrations/0014_merge_20251105_1449.py ❯ uv run src/manage.py migrate Operations to perform: Apply all migrations: account, admin, auditlog, auth, contenttypes, core, sessions, socialaccount Running migrations: Applying core.0012_remove_advanced_fields... OK Applying core.0013_add_form_config... OK Applying core.0014_merge_20251105_1449... OK ``` After that, I could start with the testing. Directly after this, navigating to e.g. `/org/my-acme-7/services/redis/offering/1/` no form is shown anymore. I would have expected to see the same form as before because I didn't configure anything yet. Trying to create a new form results in `Invalid form configuration: None is not of type 'integer'`. What am I doing wrong? ![Screenshot_20251105_160504.png](/attachments/7ac2dd5b-4a25-4b4d-a3c1-a22c4042a318) Either allow the fields to be empty or add some defaults. And when filling in all fields: ` You must include a 'name' field in the custom form config.` ![Screenshot_20251105_160830.png](/attachments/3b4fcd01-9e3f-4a62-8d5d-f682f66be538) EDIT: Got it, I must map to `name`, not `metadata.name`. I guess this is one of the fields that we need to hardcode.
Owner

Added a second fieldset, this somehow broke the view:

Added a second fieldset, this somehow broke the view: <video src="/attachments/4e076c8b-d64d-4c75-a312-af5b81c079e7" title="Screencast_20251105_161748.webm" controls></video>
Owner

A choice field allowed me to enter custom values, but ended up showing the choices from the control plane:

Screenshot_20251105_162019.png

Screenshot_20251105_162104.png

When I enter choices in the form configuration, I'd expect these to be shown (and validated against the available choices in the control plane). When I don't enter choices, the current behavior makes sense to use the available values from the control plane. This way I can override the choices if I'd like to but keep it up to the control plane when I don't configure anything.

A choice field allowed me to enter custom values, but ended up showing the choices from the control plane: ![Screenshot_20251105_162019.png](/attachments/3f4f963a-37c9-456d-96f5-e763fe44a878) ![Screenshot_20251105_162104.png](/attachments/5d78d537-c60f-4062-9ff5-8901e45113ac) When I enter choices in the form configuration, I'd expect these to be shown (and validated against the available choices in the control plane). When I don't enter choices, the current behavior makes sense to use the available values from the control plane. This way I can override the choices if I'd like to but keep it up to the control plane when I don't configure anything.
Owner

On a number field, when setting "Min value" and "Max value" I'd expect the form field to only allow these numbers in the frontend with the up- and down controls. It allows all numbers. The validation works though, a number not in the range gets rejected.

On a number field, when setting "Min value" and "Max value" I'd expect the form field to only allow these numbers in the frontend with the up- and down controls. It allows all numbers. The validation works though, a number not in the range gets rejected.
Owner

I miss a setting to set a default value on the field.

I miss a setting to set a default value on the field.
rixx added 9 commits 2025-11-06 15:15:30 +00:00
Owner

"Invalid form configuration: '64' is not of type 'integer', 'null'"

Screenshot_20251107_084828.png

Make the "Show Expert Mode" button less prominent, in practice the expert mode should only be used in rare edge cases...

The attached field definition JSON formdef.json breaks the frontend with not enough values to unpack (expected 2, got 1) stacktrace.txt

"Invalid form configuration: '64' is not of type 'integer', 'null'" ![Screenshot_20251107_084828.png](/attachments/63701cb6-673c-4202-99bc-8fd96fc3f1e8) Make the "Show Expert Mode" button less prominent, in practice the expert mode should only be used in rare edge cases... The attached field definition JSON [formdef.json](/attachments/10f1ed3f-e35b-4112-9d9a-385460a5e3d2) breaks the frontend with `not enough values to unpack (expected 2, got 1)` [stacktrace.txt](/attachments/412d50a3-2285-45ed-8f3f-3a83acde1011)
rixx added 3 commits 2025-11-07 11:59:50 +00:00
Owner

For the record:

  • Fieldsets do not work correctly on the frontend yet
  • Missing: Hard-coded fields that are always included, like "name"
  • Missing: Configurable field validators can be added later
  • Missing: Generators, for example, FQDN from name already works as expected!

Additional requirement: Many services share the same fields. So that we don't have to copy/paste between services, predefined and reusable field definitions should be made available. When configuring the service form, allow choosing from pre-defined fields.

For the record: * Fieldsets do not work correctly on the frontend yet * Missing: Hard-coded fields that are always included, like "name" * ~~Missing: Configurable field validators~~ can be added later * ~~Missing: Generators, for example, FQDN from name~~ already works as expected! Additional requirement: Many services share the same fields. So that we don't have to copy/paste between services, predefined and reusable field definitions should be made available. When configuring the service form, allow choosing from pre-defined fields.
rixx added 4 commits 2025-11-10 13:05:03 +00:00
rixx added 1 commit 2025-11-10 13:15:32 +00:00
Fix tabs for custom fieldsets
All checks were successful
Tests / test (push) Successful in 30s
f3e14b4c85
rixx added 1 commit 2025-11-10 13:37:14 +00:00
Update schema to make label and type optional
All checks were successful
Tests / test (push) Successful in 28s
45f17cabaa
rixx added 1 commit 2025-11-10 13:53:41 +00:00
Do not save empty form_config entries
All checks were successful
Tests / test (push) Successful in 30s
ffed6139cd
tobru merged commit 21102f30c7 into main 2025-11-10 14:49:33 +00:00
tobru deleted branch 165-form-configuration 2025-11-10 14:49:33 +00:00
Sign in to join this conversation.
No description provided.