title: Meteor - Add an object from a select form to a collection
body: <p>I'm trying to add a Category to my Post, so I have a form with a select box where the user can choose the category to associate with his post. The problem is that when I submit my form, I had an error because the field Category is not an object... I tried to hook the form with <code>formToDoc</code> to modify the <code>doc</code> and make the category element look good but it doesn't work. I'm guessing that I have to deal with the validation of my data but I don't know how ?</p>
  
  <p>Here are my collections CPDM and Category :</p>
  
  <pre><code>Category = new Mongo.Collection("category");
  
  // Création du schéma des catégories
  Category.attachSchema(new SimpleSchema({
      name: {
          type: String,
          label: "Catégorie",
          max: 200
      },
      value: {
          type: String,
          label: "Catégorie Value",
          max: 200
      }
  }));
  
  // Création du schéma des CPDM
  CPDM.attachSchema(new SimpleSchema({
      title: {
          type: String,
          label: "Titre",
          max: 200
      },
      content: {
          type: String,
          label: "Contenu",
          autoform: {
              afFieldInput: {
                  type: "textarea",
                  rows: 15
              }
          }
      },
      createdAt: {
          type: Date,
          autoform: {
              omit: true
          },
          autoValue: function() {
              if (this.isInsert) {
                  return new Date;
              }
              else {
                  this.unset();
              }
          }
      },
      author: {
          type: String,
          autoform: {
              omit: true
          },
          autoValue: function () {
              if (this.isInsert) {
                  if (Meteor.user()) {
                      return Meteor.user().username;
                  } else {
                      return "Anonyme";
                  }
              } else {
                  this.unset();
              }
          }
      },
      ranking: {
          type: Number,
          autoValue: function () {
              if (this.isInsert) {
                  return 0;
              }
          },
          autoform: {
              omit: true
          },
          min: 0,
          label: "Note"
      },
      voters: {
          type: [String],
          autoform: {
              omit: true
          },
          autoValue: function () {
              if (this.isInsert) {
                  return [];
              }
          }
      },
      selected: {
          type: Boolean,
          autoform: {
              omit: true
          },
          autoValue: function () {
              if (this.isInsert) {
                  return false;
              }
          }
      },
      category: {
          type: Object,
          optional: true,
          label: "Catégorie",
          autoform: {
              firstOption: "Sélectionner une catégorie"
          }
      }
  }));
  </code></pre>
  
  <p>And here is my formHook :</p>
  
  <pre><code>AutoForm.hooks({
      createCPDM: { // ID du formulaire
          formToDoc: function(doc) {
              var categoryName = $("[name='category'] option:selected").text();
              doc.category = {name:categoryName, value:doc.category};
              return doc;
          },
          onSubmit: function (doc) { // Gestion du formulaire de soumission
              var error = null;
              var title = doc.title;
              var content = doc.content;
              var category = doc.category;
              var captcha = $("#captcha").val();
  
              var formData = {
                  title: title,
                  content: content,
                  category: category
              };
  
              if (captcha == 4) {
                  Meteor.call('createCPDM', formData, function (err) {
                      if (err) {
                          error = new Error("Une erreur s'est produite");
                      }
                  });
              }
              else {
                  error = new Error("Mauvais captcha");
              }
  
              if (error === null) {
                  this.done(); // Appelle onSuccess
              }
              else {
                  this.done(error); // Appelle onError
              }
  
              return false;
          },
  </code></pre>
  
  <p>Thank's for helping !</p>