Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive validation for nested schema #1683

Closed
gilizeevi opened this issue Nov 10, 2018 · 3 comments
Closed

Reactive validation for nested schema #1683

gilizeevi opened this issue Nov 10, 2018 · 3 comments

Comments

@gilizeevi
Copy link

Hello.

I'm currently facing an issue with reactive validation errors not appearing on nested subschema fields. When adding AutoForm.debug, the errors are logged but does not show on the form.

Example:
JS

const Tasks = new Mongo.Collection('tasks');
const SubTaskSchema = new SimpleSchema({
    subtitle: {
        type: String,
        label: "Subtitle",
        required: true
    },
    price: {
        type: String,
        label: "Price",
        required: true
    }
}, { tracker: Tracker });

const TaskSchema = new SimpleSchema({
    title: {
        type: String,
        label: "Title",
    },
    subTask: {
        type: Object
    },
    'subTask.$': {
        type: SubTaskSchema
    }
}, { tracker: Tracker });
Tasks.attachSchema(TaskSchema);

HTML
{{> quickForm collection=getCollection id="insertTaskForm" type="insert"}} OR

 {{#autoForm collection=getCollection id="insertTaskForm" type="insert"}}
        <fieldset>
            <legend>Add a task</legend>
            {{> afQuickField name='title'}}
            {{> afQuickFields name='subTask.$'}}
        </fieldset>
        <button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}

In the quickform example, when subtask fields are empty, a validation error of 'subtasks is required' does appear, but not for subtasks fields.

Reactive validation errors of nested subscehma did work with previous versions, before Tracker was added. Any idea what i'm doing wrong and how to solve it?

@jamgold
Copy link

jamgold commented Jul 1, 2019

I notice the same behavior. Has anybody figured out how to solve this? The onError hook of the form has all validation errors in validationContext._validationErrors but just doesn't display it for a nested schema

@evolross
Copy link

evolross commented Feb 6, 2020

I get this too. Occurs when using either quickForm and autoForm.

Linking to your work-around that solves this problem for now.

@aldeed
Copy link
Collaborator

aldeed commented Mar 24, 2020

Duplicate of longshotlabs/simpl-schema#359, which has a PR in review / discussion

@aldeed aldeed closed this as completed Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants