Plugins can be required in the AS.form.create()
command.
Plugins can also be loaded using AS.form.plugin()
command:
AS.form.plugin('https://cdn.altersoftware.org/js-as-form/plugin/as-form-basic.js');
// If there’s no “/” in the path plugins are searched in “plugin” folder in the same folder of “as-form.js”
// So you have the same effect using simply:
AS.form.plugin('as-form-basic.js');
// …or using:
AS.form.plugin('as-form-basic');
// …and even with:
AS.form.plugin('basic');
Fields are added using the addField()
method of the AS.form
object:
let asForm = new AS.form();
asForm.addField('foo','hidden',{value:'bar'}).addField('baz','text',{mandatory:true,max:5});
asForm.render( document.getElementById('target') );
See AS.form.field documentation for common option keys and fields positioning.