[MGNLFORM-143] Exception during validation of field if getFormModel() returns null Created: 29/Nov/12  Updated: 23/Aug/22

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

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

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
Date of First Response:
Team: AuthorX

 Description   

The following method fails if a sub-mothod returns null!

Class info.magnolia.module.form.paragraphs.models.FormFieldModel

    private void validate() {
        FormField field = getFormModel().getFormField(getControlName());
        valid = field == null || field.isValid();
    }

    private AbstractFormModel getFormModel() {
        RenderingModel model = this.parentModel;
        while (model != null) {
            if (model instanceof AbstractFormModel)
                return (AbstractFormModel) model;
            model = model.getParent();
        }
        return null;
    }

if method getFormModel() returns null
the getFormModel().getFormField(getControlName()) method fails



 Comments   
Comment by Christopher Zimmermann [ 03/Dec/13 ]

FormFieldModel.validate() should first check getFormModel() for null, and log a warning if null and fail the validation.

Comment by Richard Gange [ 26/Oct/20 ]

I think what happened here is the user tried to configure one of the form sub-components. Typically the form component has a parent element which manages the individual fields of the form as a group.

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