Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoForm.getFormSchema() stopped working #790

Closed
SachaG opened this issue Mar 18, 2015 · 12 comments
Closed

AutoForm.getFormSchema() stopped working #790

SachaG opened this issue Mar 18, 2015 · 12 comments

Comments

@SachaG
Copy link
Contributor

SachaG commented Mar 18, 2015

It seems like since updating to Meteor 1.0.4 and AutoForm 5.0.2, AutoForm.getFormSchema() is not working anymore (returning undefined). Anybody else experience that?

@SachaG
Copy link
Contributor Author

SachaG commented Mar 18, 2015

What's more calling AutoForm.getFormSchema(this.atts.id) also gives me an error:

Exception in template helper: Error: No form with ID updateSettingsForm is currently rendered. If you are calling AutoForm.getCurrentDataForForm, or something that calls it, from within a template helper, try calling without passing a formId

@webyak
Copy link

webyak commented Mar 18, 2015

I experience the same after updating to 1.0.4. I'm just calling it with {{#autoForm schema='Schema.MyForm'}}

@huvber
Copy link

huvber commented Mar 18, 2015

I noticed that with quickForm does't happen so maybe there will be the solution

@aldeed
Copy link
Collaborator

aldeed commented Mar 18, 2015

Thanks, hoping to test and fix against 1.0.4 tonight. Won't have time before then, but hopefully easy fix.

@tudobala
Copy link

Not sure if related, but I'm getting this

Exception in template helper: TypeError: Cannot read property 'schema' of undefined
    at Object.getDefs (http://localhost:3000/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:255:18)
    at parseOptions (http://localhost:3000/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:1253:22)
    at Object.autoFormFieldIsInvalid (http://localhost:3000/packages/aldeed_autoform.js?95e4d3c1e4a248502de2befc9436a32b15999fa3:1276:13)
    at http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2786:16
    at http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1607:16
    at http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2834:66
    at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:12)
    at http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2833:27
    at Spacebars.call (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:18)
    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:109:25)

schema() which is

var defs = ss.schema(name);

from the snippet below

 /**                                                                                                                  // 165
   * @method Utility.getDefs                                                                                           // 166
   * @private                                                                                                          // 167
   * @param {SimpleSchema} ss                                                                                          // 168
   * @param {String} name                                                                                              // 169
   * @return {Object} Schema definitions object                                                                        // 170
   *                                                                                                                   // 171
   * Returns the schema definitions object from a SimpleSchema instance. Equivalent to calling                         // 172
   * `ss.schema(name)` but handles throwing errors if `name` is not a string or is not a valid                         // 173
   * field name for this SimpleSchema instance.                                                                        // 174
   */                                                                                                                  // 175
  getDefs: function getDefs(ss, name) {                                                                                // 176
    if (typeof name !== "string") {                                                                                    // 177
      throw new Error("Invalid field name: (not a string)");                                                           // 178
    }                                                                                                                  // 179
                                                                                                                       // 180
    var defs = ss.schema(name);                                                                                        // 181
    if (!defs) {                                                                                                       // 182
      throw new Error("Invalid field name: " + name);                                                                  // 183
    }                                                                                                                  // 184
    return defs;                                                                                                       // 185
  },

@aldeed
Copy link
Collaborator

aldeed commented Mar 19, 2015

This is due to this Meteor issue. Need to figure out how to make it work.

@tudobala
Copy link

Confirmed to be working. Thanks @aldeed. I'm a big fan of all your packages.

@webyak
Copy link

webyak commented Mar 21, 2015

Works fine for me too. That was rapid! Big thanks!

@SachaG
Copy link
Contributor Author

SachaG commented Mar 21, 2015

Thanks for the fast fix as always!

@huvber
Copy link

huvber commented Mar 25, 2015

Thanks

aramk added a commit to aramk/meteor-autoform that referenced this issue May 20, 2015
* devel: (143 commits)
  bump version
  rearrange and fix Meteor-Community-Packages#831
  bump version
  Fix validation for autoForm's with no type set
  bump version
  prevalidate method type forms only when both schema and collection are provided (fix Meteor-Community-Packages#766)
  change array handling
  ignore errors due to timing (Meteor-Community-Packages#789)
  better error for missing form id; fixes Meteor-Community-Packages#776
  move beginSubmit hook call to before prevalidation (Meteor-Community-Packages#805)
  change when formToDoc is called, add formToModifier, and optimize creating doc/mod from form (Meteor-Community-Packages#816)
  Add orion to community packages
  Update autoform-api.js
  Add try/catch to _validateField method
  Add return to afOptionsFromSchema helper
  docs
  docs
  bump version
  Meteor 1.0.4 compatibility fixes (closes Meteor-Community-Packages#790; closes Meteor-Community-Packages#794)
  minor error msg change
  ...

Conflicts:
	components/autoForm/autoForm.js
@tiagolr
Copy link

tiagolr commented Jul 30, 2015

Hi, is this bug fixed in release versions? I'm getting this error using the following versions:

Meteor: 1.1.0.2
aldeed:autoform 5.3.2
meteor-platform 1.2.2

I'm creating a basic project using meteor create and inserting an example similar to the one on the README file.

<template name="test">
  {{#autoForm id="test"}}
    <fieldset>
      <legend>Add a Book</legend>
      {{> afQuickField name='title'}}
      {{> afQuickField name='author'}}
      {{> afQuickField name='summary' rows=6}}
      {{> afQuickField name='copies'}}
      {{> afQuickField name='lastCheckedOut'}}
    </fieldset>
    <button type="submit" class="btn btn-primary">Insert</button>
  {{/autoForm}}
</template>

Thanks for confirming this bug.

@tiagolr
Copy link

tiagolr commented Jul 30, 2015

My bad it seems it does need to have an associated schema, nevermind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants