AutoForm Theme Plain
This theme contains no specific styling. Customizations are possible using
class
attributes, where desired.
Installation
Make sure you have You have two options of installing this theme.
A. Adding the theme to the initial bundle (default); comfortable but with bigger initial bundle size.
B. Using dynamic imports and adding the theme on-demand; manual effort required but lowers the footprint of the initial client bundle.
In both cases you have to install the package to your packages list:
$ meteor add communitypackages:autoform-plain
Installing using static imports (default)
You don't have to do a thing, simply adding the package will automatically make it available to your client. The only thing you need to do is either setting the theme globally or locally.
Installing using dynamic imports
This theme supports dynamic-import
so your initial client bundle will not
contain any of this package's code.
In order to do so you need to start your Meteor application with a truthy
AUTOFORM_DYNAMIC_IMPORTS
environment flag:
$ AUTOFORM_DYNAMIC_IMPORTS=1 meteor
This will cause the package to make an export available, that contains a function that dynamically loads the theme.
In order to load the theme you need to add the following code before you use the form (if the form is intended to use this theme):
1import { AutoFormPlainTheme } from 'meteor/communitypackages:autoform-plain' 2 3AutoFormPlainTheme.load() 4 .then(() => { 5 // theme is imported, you can now make the form available 6 // you could use a reactive var that resolves to true here 7 // or any other mechanism you like to use to reactively activate the form 8 }) 9 .catch(err => { 10 // handle load error 11 })
Using the theme
After installation you have to options to use the theme with your forms:
Setting the theme globally
Add the following code before you create the first form:
1AutoForm.setDefaultTemplate('plain')
Setting the theme locally
If you want this theme to apply only on certain forms you need to name it in the form declaration:
1{{#autoForm template="plain" ...}} 2 ... 3{{/autoForm}}