Skip to content

Using Onlyif but dependant on the parent viewmodel? #658

@jammy-git

Description

@jammy-git

We have a parent/child viewmodel set up so that a parent record can have multiple child records. We need a validation rule on the child record that is only required when a field on the parent has a certain value.

Is this possible?
I've tried this in the child viewmodel:
required: { onlyIf: function () { return parent.FieldX() == Value; } }
Where parent is the self variable passed from the parent viewmodel to the child viewmodel. No errors generated, but this still doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions