Input Form

A right-click style menu with multiple options and optional nested submenus.

-- Input Form
RegisterCommand('testinput', function()
    local fields = {
        {
            id = 'name',
            label = 'Full Name',
            type = 'text',
            icon = 'user',
            placeholder = 'Enter your full name',
            required = true
        },
        {
            id = 'email',
            label = 'Email Address',
            type = 'email',
            icon = 'mail',
            placeholder = 'your@email.com',
            required = true,
            pattern = '[a-z0-9._%-]@[a-z0-9.-]\\.[a-z]{2,}$'
        },
        {
            id = 'password',
            label = 'Password',
            type = 'password',
            icon = 'lock',
            placeholder = 'Enter your password',
            required = true
        },
        {
            id = 'phone',
            label = 'Phone Number',
            type = 'tel',
            icon = 'phone',
            placeholder = '(123) 456-7890',
            pattern = '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'
        },
        {
            id = 'birthdate',
            label = 'Date of Birth',
            type = 'date',
            icon = 'calendar'
        },
        {
            id = 'time',
            label = 'Preferred Time',
            type = 'time',
            icon = 'clock'
        },
        {
            id = 'website',
            label = 'Website',
            type = 'url',
            icon = 'globe',
            placeholder = 'https://example.com'
        },
        {
            id = 'age',
            label = 'Age',
            type = 'number',
            icon = 'hash',
            min = 18,
            max = 100
        },
        {
            id = 'price',
            label = 'Price',
            type = 'number',
            icon = 'dollar-sign',
            step = 0.01,
            min = 0
        },
        {
            id = 'bio',
            label = 'Biography',
            type = 'textarea',
            icon = 'file-text',
            placeholder = 'Tell us about yourself'
        }
    }

    local input = exports['moon-ui']:Input(fields, "Registration Form") -- title parameter
    
    if input then
        for k, v in pairs(input) do
            print(k, v)
        end
    else
        print('Input Form Cancelled')
    end
end)

Last updated