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

Default values not working with simpl-schema module #130

Closed
Gervwyk opened this issue Nov 10, 2016 · 8 comments
Closed

Default values not working with simpl-schema module #130

Gervwyk opened this issue Nov 10, 2016 · 8 comments
Assignees
Labels
Type: Bug Bug reports and their fixes

Comments

@Gervwyk
Copy link
Contributor

Gervwyk commented Nov 10, 2016

I've started building a uniforms-antd package to support Ant Design. Struggled to get the defaultValues working (the 'defaultValue' prop is undefined in the components), however after a while of debugging I noticed its also not working on the bootstrap versions. I substituted simpl-schema with aldeed:simple-schema and that solved the problem.

Not sure what the problem is in simpl-schema but for now I'm reverting back to the meteor package.

@radekmie
Copy link
Contributor

What exactly is not working?

Here are few probably related places in the code:
BaseField#getFieldProps
SimpleSchema2Bridge#getInitialValue
connectField#componentWillMount

@radekmie radekmie self-assigned this Nov 10, 2016
@Gervwyk
Copy link
Contributor Author

Gervwyk commented Nov 10, 2016

To fix the problem I simply replaced:

import SimpleSchema from 'simpl-schema';

with:

import {SimpleSchema} from 'meteor/aldeed:simple-schema';

in demo\assets\schemas.js and then defaultValue was set correctly in all components. Will give simpl-schema another go later this week to see if its related to my code. I'm running the demo code and only adding a new style package - uniforms-antd
Heres the fork only just started:
https://github.com/Gervwyk/uniforms/tree/uniforms-antd

@radekmie
Copy link
Contributor

Just show me your schema. There's probably some misunderstanding or some minor bug in SimpleSchema2Bridge implementation.


Nice work! How about creating a PR with the current progress of your theme package?

@Gervwyk
Copy link
Contributor Author

Gervwyk commented Nov 10, 2016

'Example - address': schema`{
        street: {
            type: String,
            max: 100,
            defaultValue: 'aaaa'
        },
        city: {
            type: String,
            max: 50,
            uniforms: {
                type: 'textarea',
                rows: 3
            }
        },
        zip: {
            type: String,
            regEx: /^[0-9]{5}$/,
            defaultValue: '11111'
        },
        number: {
            type: Number,
            label: "Number Test"
        },
        numberDec: {
            type: Number,
            label: "Number Test Deci",
            decimal: true,
            uniforms: {step: 0.1 }
        },
        boolfield: {
            type: Boolean,
            defaultValue: true
        },
        "selectTest": {
            type: String,
            allowedValues: ['aaa','bbbb','cccc','dddd'],
        },
        "multiselectTest": {
            type: [Object],
            allowedValues: [{value: 'aaa', label: 'a'},{value: 'bbb', label: 'b'},{value: 'ccc', label: 'c'},{value: 'ddd', label: 'd'}],
            uniforms: {multiple: true}
        },
        datesamplefield: {
          type: Date,
          label: "This is a date component",
          defaultValue: new Date(2015,10,2,3,4,5),
          uniforms: {
            showTime: false,
            format: "DD-MM-YYYY",
            placeholder: "Select Date",
            disabled: false,
            allowClear: false
          }
        }
    }`

This is what I have thus far. Working with aldeed package. Will switch back later this weekend to investigate.

Sweet! Will send PR when base components is done hopefully sometime next week. Great work on uniforms! Saved me 100s of hours on current project!

@radekmie
Copy link
Contributor

Great! I'll give it a try tomorrow.

@radekmie radekmie added the Type: Bug Bug reports and their fixes label Nov 19, 2016
@radekmie
Copy link
Contributor

OK, I found it. New SimpleSchema strips defaultValue. I'll try to make a workaround.

@radekmie
Copy link
Contributor

I've hacked it a little bit. It's published in v1.6.0-beta.3.

@Gervwyk
Copy link
Contributor Author

Gervwyk commented Nov 20, 2016

Thanks! This is great news. Will see if I can switch to new simple schema later this week.

@Monteth Monteth added this to Closed in Open Source (migrated) Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

No branches or pull requests

2 participants