Search code examples
meteormeteor-autoform

Saving a telephone number to Simple Schema / Collection2


I'm using autoform with simple schema and collection2. In my form I collect a phone number. Phone numbers where I live start with a 0. When it saves to the database the 0 is removed. How can I stop this from happening?

phone: {
  type: Number,
  optional: true,
  autoform: {
    afFieldInput: {
      type: "tel"
    }
  }
}

Solution

  • Numbers are stored without a leading-zero by definition - 0123 is not a valid number. You either need to add the leading zeroes when you get data out, or store the value as a string.