User can togggle predefined tags.
###Setup###
-
Install
meteor add yogiben:autoform-tags-toggle
-
Define your schema and set the
autoform
property like in the example below
Schemas = {}
@Entries = new Meteor.Collection('entries');
Schemas.Entries = new SimpleSchema
title:
type:String
max: 60
tags:
type: [String]
autoform:
type: 'tags-toggle'
afFieldInput:
tags: [
'music',
'book',
# alternatively you can set different label than tag value:
{ label: 'Movies', value: 'movies' }
]
Entries.attachSchema(Schemas.Entries)
- Generate the form with
{{> quickform}}
or{{#autoform}}
e.g.
{{> quickForm collection="Entries" type="insert"}}
or
{{#autoForm collection="Entries" type="insert"}}
{{> afQuickField name="title"}}
{{> afQuickField name="tags"}}
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
Alternatively if you want to save tags as comma separated string, use this schema:
Schemas.Entries = new SimpleSchema
title:
type:String
max: 60
tags:
type: String
autoform:
afFieldInput:
type: 'tags-toggle'
tags: [
'music',
'book',
# alternatively you can set different label than tag value:
{ label: 'Movies', value: 'movies' }
]