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.
See an example Form Lego (opens in a new tab) in the Mint a Million Tutorial
Form Blueprint
MEMBER: {
id: 'MEMBER',
title: 'Membership Proposal',
description: 'Proposal for DAO membership',
type: PROPOSAL_TYPES.MEMBER,
required: ['title', 'sharesRequested'], // Use name key from proposal type object
tx: TX.SUBMIT_PROPOSAL,
fields: [
[FIELD.TITLE, FIELD.DESCRIPTION, FIELD.LINK],
[FIELD.SHARES_REQUEST, FIELD.TRIBUTE],
],
additionalOptions: [
{
...FIELD.APPLICANT,
label: 'Applicant',
},
FIELD.LOOT_REQUEST,
FIELD.PAYMENT_REQUEST,
],
customValidations: ['nonDaoApplicant'],
}
This blueprint shows a few of the Form Lego features:
- It specifies some basic info needed to render the form:
id
title
description
- It specifies the Proposal Type, which will impact how the resulting proposal renders in the app
- It takes in a TransactionLego
TX.SUBMIT_PROPOSAL
to handle contract execution when the form submits. - It arranges the fields that appear on the form
- It handles validation for which fields are
required
. - It specifies an entry in
customValidations
Form Lego Parameters
Parameter | Data Type | Description |
---|---|---|
id | STRING | Unique identifier for the form lego. |
title | STRING | Sets the title that appears at the top of the form. |
subtitle | STRING | Sets the subtitle that appears at the top of the form. |
description | STRING | Displays on the form to describe the purpose of the form |
type | STRING | Will be incorporated into the detailsToJSON data. Creates an easy way of discorvering what type of proposal is being passed to the app later on. |
required | ARRAY OF STRINGS | values object. name key. Otherwise the form will not submit. |
tx | TX LEGO | |
fields | ARRAY OF FIELD LEGOS | Takes in an array of Field data and the factory component renders these in order. Throws an exception if it doesn't find a field component for each field.type. |
additionalOptions | ARRAY OF FIELD LEGOS | An array of field legos that can be selected on the 'Additional Options' dropdown on the form |
minionType | STRING | For minion proposals. Adds minionType to the detailsToJSON field. |
customValidations | ARRAY OF STRINGS | Can check anything inside of the application. If you want to add a custom validation head to src/utils/validation.js |
ctaText | STRING | Call To Action text. Or the name of the submit button on the form. |
blurText | STRING | If valdation isn't fulfulled this the is the text on the blur. |
formConditions | ARRAY OF STRINGS | Can change state of form based on specified condition. |
customWidth | STRING | Specifies width of form modal (800px - example). |
logValues | BOOLEAN | To log values of values of subject. Set to true debug. |