-
-
Notifications
You must be signed in to change notification settings - Fork 161
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 value #60
Comments
Can you provide an example use case? |
// lets say you create blog posts
new SimpleSchema({
visable: {
type: boolean,
defaultValue: false // not visable if not explicitly told
},
// ...
comments: {
type: [CommentSchema],
defaultValue: [] // should be an empty array on creation
}
}); I can probably think of more examples but you should get the idea. I also had the idea of making defaultValue a callback like label for multiple reasons.
city: {
type: String,
defaultValue: function () {
return (Meteor.isClient && geoLocationVariable)
? geoLocationVariable : __("city.default")
}
} With autoValue this would not work as the data is (if you documentation is correct) generated on the server which
|
But what is the overall context for this example? Because if it's an autoform, then you can use I'm not saying this shouldn't be done; it's probably a good idea, but I'd like to have a clear grasp of the legitimate use cases to make sure it's implemented correctly. It's been suggested also that a more basic autoValue should be part of simple-schema, which might make sense. Then C2 would simply extend the SS autoValue to add on the |
Wait, It may be true that there are ways with autoform and collection2 to get this functionality already. |
Yes, there is value in having a So I think I'd be OK with adding |
you are probably right... I'm always trying to make things too flexible ;) also my translations probably don't belong into a default value. however there are problems with a static value. how do you copy it safely (without making references)? |
I'll +1 the concept of a defaultValue. As the number of fields we have increases, I don't really want to program hooks or autovalues for everything - just the major cases. Just being able to set a boolean to default to true would be nice (again, simple value, not a callback). Not a must have, but just sounds convenient. |
Today's release includes a |
Liking the defaultValue, works well with the select box, automatically selects that option. Though is there anyway I can use that value to pre-fill the input box in autoform? Apologies - does work something wrong with Meteor hot code reload :( |
I can see no apparent and obvious way to set default values on array fields. I am using a custom template within which I have afArrayEachItem, but when clicking .autoform-add-item, the entry comes up blank, with no preselected value. tracking a dependency on the form.field.deps, doesn't work without using _.delay, as one cannot guarantee items have been added to the dom reactively, and surely using a default element in the field is the best option. Any direction would be handy. |
I miss an option
defaultValue
which would be inserted by the clean method. I know that collection2 delivers aautoValue
but things aren't always inserted into the database and even then it takes some of the same logic every time I want to implement a default value.The text was updated successfully, but these errors were encountered: