nestedNames:True: This will nest the form name automatically e.g:
(customField[0][title], customField[1][title])False: This will not transform the form fields name eg:
title, title
controls: Auto add controls (add and delete fields)
let form = new Stratox('#form');
form.form('theFieldName')
.setType('checkbox') // Default is "text"
.setLabel('Label')
.setDescription('Add field description')
.setAttr({ type: "email", id: "inp-email" }) // Create or overwrite html attributes
.setConfig({ pass: "configs" }) // Pass configs
.setItems({ yes: "Yes", no: "No" }) // Add (checkbox, radio or select list items)
.setFields({ ... }) // Group fields, see example bellow
.setValue("Field value");
<div id="app"></div>
let form = new Stratox('#app');
form.form('name').setLabel('Name').setValue("Jane doe");
form.form('email').setLabel('Email').setAttr({ type: "email", id: "inp-email" });
form.form('message').setType('textarea').setLabel('Message');
form.execute();
<div id="app"></div>
let form = new Stratox('#app');
form.view("ingress", {
headline: "Lorem ipsum dolor",
content: "Lorem ipsum dolor sit amet"
});
form.form('name').setLabel('Name').setValue("Jane doe");
form.form('email').setLabel('Email').setAttr({ type: "email", id: "inp-email" });
form.form('message').setType('textarea').setLabel('Message');
form.execute();
<div id="app"></div>
let form = new Stratox("#app");
form.view("ingress", {
headline: "Advanced forms",
content: "Lorem ipsum dolor sit amet"
});
form.form('name').setLabel('Name');
form.form('email').setLabel('Email');
form.form('message').setType('textarea').setLabel('Message');
form.form("customField", { type: "group" })
.setFields({
// To add component in form you just specify the type and data!
ingress: {
type: "ingress",
data: {
headline: "Repeatable fields",
content: "Even here can i combine the ingress component!"
}
},
// Add form fields with json
title: {
type: "text",
label: "Title"
},
description: {
type: "textarea",
label: "Description"
}
})
.setConfig({
nestedNames: true, // This will nest the form name automatically
controls: true // Auto add controls (add and delete fields)
})
// You can also set the values of all fields like this
// (typically passed from a database).
form.setValues({ name: "John Doe", email: "[email protected]" });
form.execute();