{"action":"created","issue":{"url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/949","labels_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/949/labels{/name}","comments_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/949/comments","events_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/949/events","html_url":"https://github.com/aldeed/meteor-autoform/issues/949","id":77692025,"number":949,"title":"Cant modify data in hidden field before insert","user":{"login":"odesey","id":3899366,"avatar_url":"https://avatars.githubusercontent.com/u/3899366?v=3","gravatar_id":"","url":"https://api.github.com/users/odesey","html_url":"https://github.com/odesey","followers_url":"https://api.github.com/users/odesey/followers","following_url":"https://api.github.com/users/odesey/following{/other_user}","gists_url":"https://api.github.com/users/odesey/gists{/gist_id}","starred_url":"https://api.github.com/users/odesey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odesey/subscriptions","organizations_url":"https://api.github.com/users/odesey/orgs","repos_url":"https://api.github.com/users/odesey/repos","events_url":"https://api.github.com/users/odesey/events{/privacy}","received_events_url":"https://api.github.com/users/odesey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-18T15:11:20Z","updated_at":"2015-05-19T19:38:21Z","closed_at":null,"body":"I hope this isn't a duplicate question, I have searched and couldn't find anything regarding the issue I am having.\r\n\r\nSo I have a schema with a few hidden fields, here is the relevant code:\r\n\r\n````\r\nOrganization.attachSchema(new SimpleSchema({\r\n  name: {\r\n    type: String,\r\n    label: \"Organization Name\",\r\n    max: 200\r\n  },\r\n  address: {\r\n      type: Object\r\n    },\r\n    'address.street': {\r\n      type: String\r\n    },\r\n    'address.street2': {\r\n      type: String,\r\n      optional: true\r\n    },\r\n    'address.city': {\r\n      type: String\r\n    },\r\n    'address.state': {\r\n      type: String,\r\n      allowedValues: [\"AL\",\"AK\",\"AZ\",\"AR\",\"CA\",\"CO\",\"CT\",\"DE\",\"FL\",\"GA\",\"HI\",\"ID\",\"IL\",\"IN\",\"IA\",\"KS\",\"KY\",\"LA\",\"ME\",\"MD\",\"MA\",\"MI\",\"MN\",\"MS\",\"MO\",\"MT\",\"NE\",\"NV\",\"NH\",\"NJ\",\"NM\",\"NY\",\"NC\",\"ND\",\"OH\",\"OK\",\"OR\",\"PA\",\"RI\",\"SC\",\"SD\",\"TN\",\"TX\",\"UT\",\"VT\",\"VA\",\"WA\",\"WV\",\"WI\",\"WY\"],\r\n      autoform: {\r\n        afFieldInput: {\r\n          firstOption: \"(Select a State)\"\r\n        }\r\n      }\r\n    },\r\n    'address.postalCode': {\r\n      type: String,\r\n      regEx: SimpleSchema.RegEx.ZipCode,\r\n      optional: false,\r\n      label: \"ZIP\"\r\n  },\r\n  location: {\r\n    type: Object,\r\n    autoform: {\r\n      type: \"hidden\",\r\n      label: false,\r\n      // omit: true\r\n    }\r\n  },\r\n    'location.latitude': {\r\n      type: Number,\r\n      defaultValue: 0.10,\r\n      decimal: true\r\n    },\r\n    'location.longitude': {\r\n      type: Number,\r\n      defaultValue: 0.10,\r\n      decimal: true\r\n    }\r\n\r\n}));\r\n````\r\n\r\nand the accompanying autoform js:\r\n\r\n````\r\nvar hooksObject = {\r\n  before: {\r\n    insert: function(doc) {\r\n      console.log(doc) //doc.location object does not exit at this point\r\n      myGeoLocationFunction(doc);\r\n      return doc;\r\n    }\r\n  }\r\n};\r\n\r\n\r\nAutoForm.hooks({\r\n  orgNew: hooksObject\r\n});\r\n````\r\n\r\nThe problem is that I am geolocating the address entered before it is stored in the database, however the ````doc.location:```` property for my object does not exist in the ````before insert```` block but it is stored in the DB with the default value.\r\n\r\nAm I doing something wrong here?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/comments/103647069","html_url":"https://github.com/aldeed/meteor-autoform/issues/949#issuecomment-103647069","issue_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/949","id":103647069,"user":{"login":"odesey","id":3899366,"avatar_url":"https://avatars.githubusercontent.com/u/3899366?v=3","gravatar_id":"","url":"https://api.github.com/users/odesey","html_url":"https://github.com/odesey","followers_url":"https://api.github.com/users/odesey/followers","following_url":"https://api.github.com/users/odesey/following{/other_user}","gists_url":"https://api.github.com/users/odesey/gists{/gist_id}","starred_url":"https://api.github.com/users/odesey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odesey/subscriptions","organizations_url":"https://api.github.com/users/odesey/orgs","repos_url":"https://api.github.com/users/odesey/repos","events_url":"https://api.github.com/users/odesey/events{/privacy}","received_events_url":"https://api.github.com/users/odesey/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T19:38:21Z","updated_at":"2015-05-19T19:38:21Z","body":"The issue has nothing to do with server vs client. The issue is that I simply cannot change the default values before they are inserted into the database. I have tried the following:\r\n\r\n1 - A method call like you suggested for the form type\r\n2 - A ````Meteor.call('myGeoLocateFunction', doc, function(error, result)```` and changing the value      both on the client and on the server\r\n3 - A client side ````geoLocationFunction(doc)````\r\n4 - Simply putting ````doc.location = {}```` followed by ````doc.location.latitude = 123456````\r\n\r\nAll result with the property value being updated BUT inserted into the database with the default value.\r\n\r\nHopefully that explains it better.\r\n"}}