Input

Functions

input(name, options)

Creates and displays an input form with various field types.

Parameters:

  • name (string, optional): Title of the input form. Defaults to 'Input Menu' if not provided

  • options (table): Array of input field configurations, each containing:

    • type (string): Input field type ('text', 'number', 'select', 'checkbox', 'textarea')

    • title (string): Label text for the input field

    • placeholder (string/number, optional): Placeholder text or default value

    • required (boolean, optional): Whether the field is required

    • description (string, optional): Additional description text

    • min (number, optional): Minimum value for number inputs

    • max (number, optional): Maximum value for number inputs

    • options (table, optional): Options array for select inputs with label and value properties

Returns:

  • result (table): Form data with field values, or nil if cancelled

Exports:

  • Standard Export: exports['ps-lib']:input(name, options)

  • PS-UI Export (Legacy Support): exports['ps-ui']:input(name, options)

Input Field Types

Text Input

{
    type = 'text',
    title = 'Enter your name',
    placeholder = 'Full Name',
    required = true
}

Number Input

{
    type = 'number',
    title = 'Enter amount',
    placeholder = 100,
    required = true,
    min = 1,
    max = 999999
}

Select Dropdown

{
    type = 'select',
    title = 'Choose option',
    options = {
        { label = 'Option 1', value = 'opt1' },
        { label = 'Option 2', value = 'opt2' }
    },
    required = false
}

Checkbox

{
    type = 'checkbox',
    title = 'Accept terms',
    description = 'I agree to the terms and conditions',
    required = true
}

Textarea

{
    type = 'textarea',
    title = 'Comments',
    placeholder = 'Enter your comments here...',
    required = false
}

Usage Examples

Basic User Registration Form

local function showRegistrationForm()
    local options = {
        {
            type = 'text',
            title = 'First Name',
            placeholder = 'Enter first name',
            required = true
        },
        {
            type = 'text',
            title = 'Last Name',
            placeholder = 'Enter last name',
            required = true
        },
        {
            type = 'number',
            title = 'Age',
            placeholder = 18,
            required = true,
            min = 16,
            max = 100
        },
        {
            type = 'select',
            title = 'Gender',
            options = {
                { label = 'Male', value = 'male' },
                { label = 'Female', value = 'female' },
                { label = 'Other', value = 'other' }
            },
            required = true
        }
    }
    
    local result = exports['ps-lib']:input('Character Registration', options)
    
    if result then
        TriggerServerEvent('character:create', result)
        ps.notify('Character created successfully!', 'success')
    else
        ps.notify('Registration cancelled', 'error')
    end
end

Last updated