Form Legos
Form legos are composed of transaction legos and field legos. Once complete, a form can collect information from the user and trigger a transaction to a smart contract.
Github (opens in a new tab)
Usage
Examples
How to make a form lego
This form uses an existing tx lego. Learn about making new transaction legos.
This form uses a mix of existing field legos and one custom lego. Learn about making new field legos.
import { MolochFormLego } from '@daohaus/moloch-v3-fields';
import { TX, FIELD } from '@daohaus/moloch-v3-legos';
const simpleForm = {
id: 'SIMPLE',
title: 'Simple Title',
subtitle: 'Simple Subtitle',
description: 'Super simple description.',
requiredFields: { title: true, simpleCustomField: true },
log: true,
tx: TX.SOME_SIMPLE_TX,
fields: [
{ ...FIELD.TITLE, label: 'Simple Label' },
FIELD.LINK,
{
id: 'simpleCustomField',
type: 'textarea',
label: 'Tell me something?',
placeholder: 'Please?',
},
],
};
Properties | |
---|---|
id | Arbitrary identifier. Should be unique |
title | Main form headline |
title | Small text above the title |
title | Paragraph below the title |
tx | Transaction lego |
fields | Array of field legos |
requiredFields | An object with the field id of any required fields |
log | If set to true the form builder logs out form values in the console for help during development |
submitButtonText | Overrides the default submit button text ('Submit') |