QBCore Frameworkqbcore.netCommunity docs
On this page

Updated 2026-09-21 · 4 min read

qb-input

qb-input opens a client-side form through exports['qb-input']:ShowInput(...). It returns submitted values, or nil when closed. Field names become the keys you read from the result. The example below is a complete local preview resource: there is no missing server event and no claim that form submission saves data.

Source baseline: 379f8b74. Field types, options and styling conventions come from its README. The walkthrough is source-reviewed; execute the staging checks yourself before adapting it.

Where the example belongs

Create resources/[local]/qbnet-input-demo/. Start qb-input and its dependencies on a working staging server first. The form must run in a client script, not a server Lua file or an ordinary web browser.

fxmanifest.lua

fx_version 'cerulean'
game 'gta5'
client_script 'client.lua'
dependency 'qb-input'

client.lua

local formOpen = false
local categories = { general = true, vehicle = true }

RegisterCommand('qbnet-form', function()
    if formOpen then return end
    if GetResourceState('qb-input') ~= 'started' then
        print('[form-demo] Start qb-input first.')
        return
    end

    formOpen = true
    local ok, result = pcall(function()
        return exports['qb-input']:ShowInput({
            header = 'Local note preview',
            submitText = 'Preview',
            inputs = {
                {
                    text = 'Note (maximum 80 bytes)',
                    name = 'note',
                    type = 'text',
                    isRequired = true
                },
                {
                    text = 'Priority (1 to 5)',
                    name = 'priority',
                    type = 'number',
                    default = 1,
                    isRequired = true
                },
                {
                    text = 'Category',
                    name = 'category',
                    type = 'select',
                    default = 'general',
                    options = {
                        { value = 'general', text = 'General' },
                        { value = 'vehicle', text = 'Vehicle' }
                    }
                }
            }
        })
    end)
    formOpen = false

    if not ok then
        print('[form-demo] Form failed; inspect the qb-input client error.')
        return
    end
    if result == nil then
        print('[form-demo] Cancelled; nothing was saved.')
        return
    end
    if type(result) ~= 'table' then return end

    local note = type(result.note) == 'string' and result.note or ''
    note = note:match('^%s*(.-)%s*$')
    local priority = tonumber(result.priority)
    local category = result.category

    if #note == 0 or #note > 80 then
        print('[form-demo] Enter a note of 1 to 80 bytes.')
        return
    end
    if not priority or priority % 1 ~= 0 or priority < 1 or priority > 5 then
        print('[form-demo] Priority must be an integer from 1 to 5.')
        return
    end
    if type(category) ~= 'string' or not categories[category] then
        print('[form-demo] Choose a listed category.')
        return
    end

    print(('[form-demo] Preview only: category=%s priority=%d noteBytes=%d'):format(
        category, priority, #note
    ))
end, false)

The demo intentionally logs only category, priority and note length, not the note itself. Lua's # measures string bytes here, so non-ASCII text can reach the limit before 80 visible characters. Adapt the validation and user-facing label together for a production multilingual form.

In the server console, run refresh, then ensure qbnet-input-demo. In in-game chat, run /qbnet-form. Read the preview result in F8. In F8 itself, the command is qbnet-form without a slash. Close the form before stopping the demo resource.

The manifest format follows Cfx.re's resource reference. There is no SQL import, saved note, billing action or myresource:server:saveNote dependency in this demo.

Choose field names and options

TypeSuitable useImportant detail
textShort labels or notesGive it a unique name; bound length where used
passwordMasked presentation of a non-sensitive game valueMasking does not secure the data flow
numberNumeric inputConvert and validate; do not assume a Lua number
radioOne choiceMatch defaults to an option's value
checkboxSeveral selectionsInspect the README's option/return conventions before consuming them
selectOne choice from a listAllowlist the submitted value, not the displayed label
colorA color choiceValidate the expected color format at its destination

Supported fields include text, name, type, isRequired, default and, for relevant types, options. Use lowercase type names. Reusing the same field name can overwrite the result you expected. Optional fields may not supply the value your code assumes; check before indexing or converting.

Saving data safely

The example performs no persistent action. To add one, design a separate server handler: obtain the player from the connection's source, validate the types and bounds again, check ownership or job permission against server-owned state, apply rate limits, then report the actual persistence result.

Never accept a client-supplied owner ID, price or permission flag as authority. isRequired and the number field are interface helpers, not server protection. A selected plate is not proof of vehicle ownership. Use safe server events and the NUI callback guide for that boundary.

Do not collect real account passwords through an in-game form. Avoid logging full player-submitted values while diagnosing an issue.

Customize qb-input styling

The pinned README describes copying html/styles/default.css to a named stylesheet and setting Config.Style to that name. Verify the file is packaged and loaded on staging. Keep field names, option values, submit handling and cancellation intact while styling.

For a list of actions rather than form fields, use qb-menu. For a fully custom browser interface, follow the NUI form guide instead of replacing qb-input's contract accidentally.

Troubleshooting and acceptance checks

Test or symptomExpected result or diagnosis
Submit a short note with priority 1F8 shows a preview, not a saved-record message
Cancel the formCancellation is handled before reading result fields
Submit empty/whitespace-only textRequired-field or local validation rejects it
Supply an out-of-range or fractional priorityInteger/range check rejects it
Select each categoryThe returned value matches the allowlist
Open repeatedlyNo second local demo form opens while the first is active
No form appearsCheck client context, dependency startup and the first Lua/NUI error
Field is missingCheck cancellation, optional status and exact unique name
A custom save feature does nothingInspect its separate server handler and database result

These are manual FiveM test instructions, not completed runtime results. To undo the demo, close it, stop qbnet-input-demo and remove its startup entry; no player data needs restoring. Return to resource references.

Found an issue in this guide?

Send the page URL, the affected example, and a source or reproduction to the site maintainer. For a server or resource problem, use the support guide.

On this page

Leonida RP server website built with RPWebsite
RPWebsite

Advertisement · RPWebsite

Want a website for your server?

Launch a site with live player status, rules, and a join button in minutes.

Build your website