Fields
Search Field

Search

This field selects an option from a list of options and can also be used to search within the options list.

Display type

  • search

Basic example

Schema

{
fields
:
[
0
:
{
name
:
"countries"
meta
:
{
displayName
:
"Select Country"
displayType
:
"search"
value
:
"IN"
options
:
[
0
:
{
…
}
1
:
{
…
}
]
}
}
]
}

Field Properties

NameDescription
displayTypeThe displayType for this field (select)
displayNameThe display name used for this field
optionsThe list of available options for the field
valueThe value used by this field
placeholderThe hint value used for this field
isDisabledMarks the field as disabled
isReadonlyMarks the field as readonly

Config

The configuration defines how to load dropdown options for the select field. Use this to load options from remote api and configure its behaviour.

NameDescription
urlThe api endpoint to load dropdown options
pathParamsThe path parameters of the url. Use this for dynamic path parameters
queryParamsList of query parameters. Use this for dynamic query parameters
valueKeyThe key from the response for value of the field
labelKeyThe key from the response for display name of the field
responseKeyThe key from response which contains the results
lazyLoad options lazily. For example: load the options on opening dropdown

Query params

Query params can be used to pass additional data as part of the api url. This data can either be hardcoded or configured to pass data dynamically from other fields.

Format of query params: It accepts an array/list of query params.

[<QUERY_PARAM1>, <QUERY_PARAM2>,...]

Format of query param: It accepts name and value in list like format.

[<NAME_OF_QUERY_PARAM>, <VALUE_OF_QUERY_PARAM>]
  • NAME_OF_QUERY_PARAM is just a string
  • VALUE_OF_QUERY_PARAM can be a hardcoded value or can reference value from another field like this:
    • type: 'fieldValue' indicates the value has to be taken from another field
    • ref: name of the reference field from where value can be copied

Sample form usage with api information:

import MuiForms from "mui-forms";
 
function Form() {
    return (
        <MuiForms
            config={{
                variant: "outlined"
            }}
            rest={{
                config: {
                    apihost: "",
                    basepath: "/api/v0/rockets"
                }
            }}
            schema={schema}
            onSubmit={() => {
                // handle submit
            }}
        />
    );
}

Star us at github

© Copyright 2023 MuiForms