Skip to content

Files

Latest commit

 

History

History
71 lines (47 loc) · 1.56 KB

error-creating-form.md

File metadata and controls

71 lines (47 loc) · 1.56 KB

Error Creating Form

image

This happens when a form does not have required data in a ModalFormData, ActionFormData or MessageFormData class.

To solve this, you need to have required setting included in your script.

Modal Form Data

const ModalForm = new ModalFormData();

// Required
ModalForm.title(titleText: string);

// One of the following are needed: Dropdown / Slider / Textfield / toggle
ModalForm.dropdown(label: string, options: string[], defaultValueIndex?: number);

ModalForm.slider(label: string, minimumValue: number, maximumValue: number, valueStep: number, defaultValue?: number);

ModalForm.textField(label: string, placeholderText: string, defaultValue?: string);

ModalForm.toggle(label: string, defaultValue?: boolean);

// Show form to player
ModalForm.show(player: Player);

Example:

new ModalFormData().title('ModalFormData')
                   .dropdown('Dropdown', ['Option 1', 'Option 2'])
                   .show(player)

Message Form Data

const form = new MessageFormData();

// required
form.title('Title');
form.body('Body');

// optional
form.button1('button1');
form.button2('button2');

// Show form to player
ModalForm.show(player);

Action Form Data

import { ActionFormData } from '@minecraft/server-ui';

const action = new ActionFormData();

// required
action.title('title');
action.body('body');

// require at least one button
action.button('button');

// show
action.show(player);