[MGNLFORM-394] Change template can lead to a broken form Created: 13/Sep/23  Updated: 14/Sep/23

Status: Open
Project: Magnolia Form Module
Component/s: None
Affects Version/s: 2.7.8
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File error-log.txt     PNG File form-fields.png    
Issue Links:
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: AuthorX Support
Team: AuthorX

 Description   

There are some cases when using the change template button where the form can become completely broken. A couple of cases are when switching fields.

  • Going from an Input field to a Selection field
  • Going from a Number or date field to a Selection field

Reproduce

Error while rendering [/travel/contact/main/01/fieldsets/formGroupFields/fields/email] with template [form:components/formSelection] for URI [/travel/contact.html?mgnlPreview=false&mgnlChannel=desktop]:
RenderException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> content.horizontal  [in template "form/components/formSelection.ftl" at line 26, column 17]

----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: ${content.horizontal?string('class="m...  [in template "form/components/formSelection.ftl" at line 26, column 15]
----

Expected
I should be able to change template without breaking the form.

Actual
Form enters an unusable state. Cannot recover from the page editor.

Workaround
Use the JCR Browser to fix the form.


Generated at Mon Feb 12 05:39:46 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.