0.0.1 • Published 4 years ago
@tina-form/image-field v0.0.1
tina-form
Inspiring by TinaCMS, but focusing on how to construct a form only.
How to use
1. Define your form
const fields = [
{name: 'name', label: 'Name', component: 'text'},
{name: 'avatar', label: 'Avatar', component: 'image'},
{
name: 'background', label: 'Background', component: 'color', widget: 'block',
colors: [
'red',
'black',
'green'
]
},
{name: 'age', label: 'Age', component: 'number'},
{name: 'enabled', label: 'Enabled', component: 'boolean', defaultValue: false},
...
]
2. Create the form
const form = createForm({
initialValues: initValues,
onSubmit: async (values) => {
console.log("onSubmit form with values:", values);
},
fields: fields
});
3. Using FormBuilder to render
<FormBuilder form={form} />
For more detail, please refer to demo code.
How to run demos
yarn install
yarn build
yarn start-demo
0.0.1
4 years ago