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

TypeError: Cannot read property 'slice' of null for Object.autoFormGetSchemaForField [as getLabelForField] #16

Open
balasivagnanam opened this issue Jun 16, 2015 · 6 comments

Comments

@balasivagnanam
Copy link

Not sure if this is because of any versions or dependency, my autoform is not working and I am getting this error, I have the screenshot and the schema code, form code below,
image

<template name="assesmentNew">
  {{#ionModal customTemplate=true}}
    {{# autoForm collection="Assesments" id="assesments-new-form" type="insert"}}
      <div class="bar bar-header bar-stable">
        <button data-dismiss="modal" type="button" class="button button-clear">Cancel</button>
        <h2 class="title">New Assesment</h2>
        <button type="submit" class="button button-positive button-clear">Save</button>
      </div>
      <div class="content has-header overflow-scroll">
        {{> afQuickField name="name" }}
        {{> afQuickField name="email"}}
        {{> afQuickField name="category"}}
        {{> afQuickField name="location"}}
      </div>
    {{/autoForm}}
  {{/ionModal}}
</template>
Assesments = new Mongo.Collection('assesments');

Assesments.before.insert(function (userId, doc) {
  doc.createdAt = new Date();
});


Assesments.attachSchema(new SimpleSchema({
  name: {
   type: String,
    label: 'First Name',
    autoform: {
      'label-type': 'floating',
      placeholder: 'First Name'
    }
  },
  email: {
    type: String,
    label: 'Email',
    autoform: {
      'label-type': 'floating',
      placeholder: 'Email'
  }
  },
  category: {
    type: String,
      label: 'Category',
    optional: true,
    autoform: {
      options: [
        {value: 'General', label: 'General'},
        {value: 'Reported', label: 'Reported'},
        {value: 'Follow Up', label: 'Follow Up'}
      ],
      type: 'select-radio'
    }
  },
 assesmentDate: {
    type: Date,
    label: 'Assesment Date',
    optional: true
  },
  location: {
    type: String,
      label: 'Location',
      autoform: {
      'label-type': 'floating',
      placeholder: 'Location'
    },
    max: 200
  },
 createdBy: {
    type: String,
    autoValue: function() {
    return this.userId
  }
}
  }
    ));

if (Meteor.isServer) {
  Assesments.allow({ 
    insert: function (userId, doc) {
      return true;
    },
    update: function (userId, doc, fieldNames, modifier) {
      return true;
    },
    remove: function (userId, doc) {
      return true;
    }
  });
}
@balasivagnanam
Copy link
Author

I solved this by adding

autoform: {
   'label-type': 'placeholder',
   placeholder: 'Linha'
}

to all the schema fields being rendered by autoform

http://stackoverflow.com/questions/30858068/typeerror-cannot-read-property-slice-of-null/30858124#30858124

Thanks to @rafaelquintanilha

@timbrandin
Copy link
Contributor

+1 also getting this issue with version 5.3 of autoform.

@balasivagnanam
Copy link
Author

Thanks @timbrandin for notifying, @nickw thanks for the fix... will check the case and close it..

@timbrandin
Copy link
Contributor

@balasivagnanam your welcome :)

@maabed
Copy link
Contributor

maabed commented Aug 9, 2015

The same issue happen when using array of string like below

  tags:
    type: [String]
    optional: true
    minCount: 1
    maxCount: 4

array

@maabed
Copy link
Contributor

maabed commented Aug 10, 2015

Solve this by changing options="auto" to options=afOptionsFromSchema in L87

maabed added a commit to maabed/autoform-ionic that referenced this issue Aug 10, 2015
nickw pushed a commit that referenced this issue Aug 10, 2015
Fixed some issues regarding array types in Autoform 5.3 #16
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

3 participants