I am playing around with Meteor and autoform.
My setup
I have an input field (type "time") as part of my schema for the collection of "Songs" that forces the user to type the syntax [num][num]:[num][num]. This is my schema:
time: {
type: Number,
label: "Time",
optional: true,
autoform: {
afFieldInput: {
type: 'time'
}
}
}
What I want to do
After hitting "submit" but before validation I want to convert the string (e.g. "03:45") to seconds (Number) so that the validation passes without an error.
Also: when reading the data from the db I want to convert it back to a string, so that it fits in the input field as a value.
I could not find the answer in the docs for autoform, collection2 or simple-schema (or at least did not understand it ;-)
Thanks for your help!
autoValue: function() {}
in the Sings schema. I did not try the way back from the db to the form yet. Another thing is, that I need the ID of the album as an attribute for the song-doc. Without autoform I had passed it from the template helper as an parameter to theMeteor.call()
, but with autoform I don't know the best way to do it. Maybe via hidden input field? Or any more fancy way? – CeeJay84