{"action":"created","issue":{"url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/1221","labels_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/1221/labels{/name}","comments_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/1221/comments","events_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/1221/events","html_url":"https://github.com/aldeed/meteor-autoform/issues/1221","id":108542166,"number":1221,"title":"afFieldValueIs not working when form initially loads","user":{"login":"mbabauer","id":472616,"avatar_url":"https://avatars.githubusercontent.com/u/472616?v=3","gravatar_id":"","url":"https://api.github.com/users/mbabauer","html_url":"https://github.com/mbabauer","followers_url":"https://api.github.com/users/mbabauer/followers","following_url":"https://api.github.com/users/mbabauer/following{/other_user}","gists_url":"https://api.github.com/users/mbabauer/gists{/gist_id}","starred_url":"https://api.github.com/users/mbabauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbabauer/subscriptions","organizations_url":"https://api.github.com/users/mbabauer/orgs","repos_url":"https://api.github.com/users/mbabauer/repos","events_url":"https://api.github.com/users/mbabauer/events{/privacy}","received_events_url":"https://api.github.com/users/mbabauer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-27T15:23:48Z","updated_at":"2015-09-28T13:46:15Z","closed_at":null,"body":"In my Autoform, I need to show/hide a section of date pickers based on the state of a dropdown:\r\n\r\n```javascript\r\n<div class=\"form-group col-md-6\">\r\n\t<label>Assignment State</label>\r\n\t{{> afFieldInput name=\"state\" id=\"state\" disabled=\"disabled\"}}\r\n</div>\r\n{{#if afFieldValueIs name=\"state\" value=\"Approved\"}}\r\n\t<div class=\"col-md-6\">\r\n\t\t<div class=\"form-group\">\r\n\t\t\t<label for=\"scheduledAt\">Scheduled Date/Time</label>\r\n\t\t\t{{> afFieldInput name=\"scheduledAt\" id=\"scheduledAt\" disabled=\"disabled\"}}\r\n\t\t</div>\r\n\t\t<div class=\"form-group\">\r\n\t\t\t<label for=\"estimatedCompletion\">Estimated Completion</label>\r\n\t\t\t{{> afFieldInput name=\"estimatedCompletion\" id=\"estimatedCompletion\" disabled=\"disabled\"}}\r\n\t\t</div>\r\n\t</div>\r\n{{/if}}\r\n```\r\n\r\nThe form is loaded by selecting the value in a Bootstrap list group.  The user selects a value on the left, which sets a `Session` value that triggers the load of the form, in read-only mode, on the right.\r\n\r\nHowever, upon initial run, the `if` test on `template.view._domrange` fails in the following code (lines 422-426) because the value of `template.view._domrange` at that point is `false`:\r\n```javascript\r\n/**                                                                                                                    // 392\r\n * @method AutoForm.getFieldValue                                                                                      // 393\r\n * @public                                                                                                             // 394\r\n * @param {String} fieldName The name of the field for which you want the current value.                               // 395\r\n * @param {String} [formId] The `id` attribute of the `autoForm` you want current values for. Default is the closest form from the current context.\r\n * @return {Any|undefined}                                                                                             // 397\r\n *                                                                                                                     // 398\r\n * Returns the value of the field (the value that would be used if the form were submitted right now).                 // 399\r\n * This is a reactive method that will rerun whenever the current value of the requested field changes. Return value will be undefined if the field is not currently rendered.\r\n */                                                                                                                    // 401\r\nAutoForm.getFieldValue = function autoFormGetFieldValue(fieldName, formId) {                                           // 402\r\n  // find AutoForm template                                                                                            // 403\r\n  var template = Tracker.nonreactive(function () {                                                                     // 404\r\n    return AutoForm.templateInstanceForForm(formId);                                                                   // 405\r\n  });                                                                                                                  // 406\r\n                                                                                                                       // 407\r\n  if (!template) {                                                                                                     // 408\r\n    if (formId) {                                                                                                      // 409\r\n      AutoForm.rerunWhenFormRenderedOrDestroyed(formId);                                                               // 410\r\n    }                                                                                                                  // 411\r\n    return;                                                                                                            // 412\r\n  }                                                                                                                    // 413\r\n                                                                                                                       // 414\r\n  // reactive dependency                                                                                               // 415\r\n  template.formValues = template.formValues || {};                                                                     // 416\r\n  if (!template.formValues[fieldName]) {                                                                               // 417\r\n    template.formValues[fieldName] = new Tracker.Dependency();                                                         // 418\r\n  }                                                                                                                    // 419\r\n  template.formValues[fieldName].depend();                                                                             // 420\r\n                                                                                                                       // 421\r\n  if (!template.view ||                                                                                                // 422\r\n      !template.view._domrange ||                                                                                      // 423\r\n      template.view.isDestroyed) {                                                                                     // 424\r\n    return;                                                                                                            // 425\r\n  }                                                                                                                    // 426\r\n                                                                                                                       // 427\r\n  var doc = AutoForm.getFormValues(formId, template, null, false);                                                     // 428\r\n  if (!doc) {                                                                                                          // 429\r\n    return;                                                                                                            // 430\r\n  }                                                                                                                    // 431\r\n                                                                                                                       // 432\r\n  var mDoc = new MongoObject(doc);                                                                                     // 433\r\n  var value = mDoc.getValueForKey(fieldName);                                                                          // 434\r\n                                                                                                                       // 435\r\n  return value;                                                                                                        // 436\r\n};     \r\n```\r\n\r\nAs a result, the afFieldValueIs is not evaluated, and my dynamically shown fields are not show, despite the value for `state` being `\"Approved\"`.\r\n\r\nHow can I trigger my fields to be properly rendered based on the `state` value?"},"comment":{"url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/comments/143747854","html_url":"https://github.com/aldeed/meteor-autoform/issues/1221#issuecomment-143747854","issue_url":"https://api.github.com/repos/aldeed/meteor-autoform/issues/1221","id":143747854,"user":{"login":"abernix","id":841294,"avatar_url":"https://avatars.githubusercontent.com/u/841294?v=3","gravatar_id":"","url":"https://api.github.com/users/abernix","html_url":"https://github.com/abernix","followers_url":"https://api.github.com/users/abernix/followers","following_url":"https://api.github.com/users/abernix/following{/other_user}","gists_url":"https://api.github.com/users/abernix/gists{/gist_id}","starred_url":"https://api.github.com/users/abernix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abernix/subscriptions","organizations_url":"https://api.github.com/users/abernix/orgs","repos_url":"https://api.github.com/users/abernix/repos","events_url":"https://api.github.com/users/abernix/events{/privacy}","received_events_url":"https://api.github.com/users/abernix/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T13:46:14Z","updated_at":"2015-09-28T13:46:14Z","body":"Alternatively, and pretty much just for fun, if you want to see if it's actually the same bug, force your autoform to 5.4.0 (if you don't have other dependencies that prevent it – which you might):\r\n\r\n`meteor add aldeed:autoform@=5.4.0`"}}