-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Update BaseField.js #262
Update BaseField.js #262
Conversation
In my case i was wanting to use conditional required value for a field. Maybe the way Custom works is the thing we need https://github.com/aldeed/meteor-simple-schema#custom |
Isn't it a breaking change? |
Yea @janowsiany maybe, and maybe it is not needed xD I was just trying to make a field required in a conditional way but @radekmie suggested a PR. Might it be enough using the This should work, but it is not working. |
I am WRONG in following statement const Custom => ({required, ...props}, {uniforms: {model}}) => (
<TextField required={model.otherField !== 1} {...props} />
);
export default connectField(Custom); This example should make field required only if value of |
@janowsiany With this code i should make one custom field for each type of field i want to use with custom required... Sorry but the amount of work it makes me do... it's not acceptable. (since simpleschema has a custom attribute or i could just pass required=true to fields) |
I was completely wrong, but uniforms do support even custom validations sorry for this confusion. |
This was working with aldeed autoforms.
|
Ok so here is a schema which works in demo app: new SimpleSchema({
adult: {
type: Boolean,
optional: true,
custom: function() {
if (this.field('size').value === 'm' && !this.value) {
return 'required';
}
}
},
size: {
type: String,
defaultValue: 'm',
allowedValues: ['xs', 's', 'm', 'l', 'xl']
},
}) Am i missing something? |
Why did I want to see this PR? Because it's more reasonable, to make direct props more important than schema ones. I'm still thinking about consequences, but it's more like a bugfix, than a feature. |
To be honest, I have very mixed feelings about it... I'd love to merge it, but it is a kind of breaking change... No matter what, it's still a kind of bug fix because that's how it should behave... How about this: let's release a new version ( |
Probably it will be a breaking change yes. But, yeah.. makes sense. I have not tested that in our project so I don't know if anything is going to break. I suspect there will be major issues. Maybe it will affect more to people with custom fields. |
OK, then I'll release |
@rafinskipg I had to fix it, because after your changes |
Make field properties more important than schema properties