You're a developer, and the most annoying thing you can do are forms.
So, let's build forms with just an object literal.
gittio install com.caffeinalab.titanium.formbuilder
Download the latest release and add in your config.json, under dependencies
:
"dependencies": {
"com.caffeinalab.titanium.formbuilder": "*"
}
var form = Alloy.createWidget('com.caffeinalab.titanium.formbuilder', {
fields: [
{ name: 'first_name' },
{ name: 'last_name' },
// See below
]
});
Possible values are:
text
password
passwordEye
email
boolean
It must return true
if everything's ok, a message string otherwise.
var fields = [
{
name: 'email',
type: 'email',
label: 'EMAIL',
placeholder: '[email protected]',
group: 'I tuoi dati di accesso',
required: true,
validator: function(value) {
if (!/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i.test(value)) {
return "Email non valida";
}
return true;
}
},
{
name: 'password',
type: 'passwordEye',
label: 'LA TUA PASSWORD',
placeholder: 'Password',
group: 'I tuoi dati di accesso',
required: true,
validator: function(value) {
if (value.length < 8) return "Inserisci una password di almeno 8 caratteri";
return true;
}
},
{
name: 'first_name',
type: 'text',
label: 'NOME',
placeholder: 'Mario',
required: true,
group: 'Le tue informazioni personali'
},
{
name: 'privacy',
type: 'boolean',
label: 'PRIVACY POLICY',
placeholder: 'Ho letto e accettato la privacy policy',
required: true,
group: 'Consenso'
}
];
Just overwrite classes with app/themes/YOURTHEME/com.caffeinalab.titanium.formbuilder/styles/widget.tss
How to get involved:
- Star the project!
- Answer questions that come through GitHub issues
- Report a bug that you find
Pull requests are highly appreciated.
Solve a problem. Features are great, but even better is cleaning-up and fixing issues in the code that you discover.
Copyright 2015 Caffeina srl under the MIT license.