-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Overview
inputs is a property that can be defined in a plugin's manifest.yml file. An "input" is an expected value that can be provided to the plugin at runtime. Here's an example input definition:
inputs:
- name: phone
label: Twilio Phone Number
required: true
pattern: /^([0-9\(\)\/\+ \-]*)$/
sensitive: trueNot all inputs are required. An input definition can be used to validate user input, as well as configure the UI that might be presented for the user to provide their input. For example, a "select" type input might result in an HTML <select> element for the user to select a value. Note that inputs might come from anywhere (Eg., another plugin, CLI, etc.), so a UI may not always be involved.
Why this is important
This API is meant to drive a dynamic UI in the Netlify dashboard, completely configured through a plugin's manifest.yml. It is similar in concept to the editor pane in Netlify CMS, except:
- we're only configuring a form
- nothing is previewed
- only simple values are handled (no crazy markdown widgets)
Default input properties
These properties are available to all inputs, regardless of type.
| key | required | default | description |
|---|---|---|---|
name |
yes | name for internal reference purposes | |
label |
yes | proper display name for UI | |
type |
"string" |
UI input type (see Available types below) | |
description |
Longer description | ||
required |
false |
Set field as required | |
default |
Default value used if none supplied | ||
repeat |
false |
Whether the field can be repeated - produces an array of values if true |
|
repeat_min |
Minimum repeat count (if repeat is true) |
||
repeat_max |
Maximum repeat count (if repeat is true) |
Here's an example use case for the repeat property, where a plugin accepts a list of email addresses. The user could add as many email addresses as necessary since repeat is set to true.
inputs:
- name: emails
label: Email Addresses
required: true
repeat: true
repeat_min: 1Available types
A list of types that we should allow, and type-specific properties that should be accepted for each.
string
Accepts a string value.
| key | required | default | description |
|---|---|---|---|
pattern |
Regular expression that this string should match. | ||
sensitive |
false |
Whether to mask the value to prevent it from being displayed in logs, CLI, or API. |
number
Accepts a numeric value.
| key | required | default | description |
|---|---|---|---|
min |
Minimum acceptable value. | ||
max |
Maximum acceptable value. |
boolean
Accepts a boolean value.
No type-specific properties.
text
Longer string value.
No type-specific properties.
select
Accepts one or more values from a predefined list.
| key | required | default | description |
|---|---|---|---|
options |
yes | List of values that can be selected. | |
multiple |
false |
Allow multiple values to be selected |
object
Accepts a map of inputs.
| key | required | default | description |
|---|---|---|---|
inputs |
yes | Map of input definitions |
Here's an example input configuration that accepts an array of address objects.
inputs:
- name: addresses
label: Addresses
type: object
required: true
repeat: true
repeat_min: 1
inputs:
- name: street_address
label: Street Address
required: true
- name: city
label: City
required: true
- name: state
label: State
required: true