Skip to content

FieldButton

FieldButton is a field component that renders a standard HTML button element.

type button

Basic example

Code
javascript
{
  type: 'button',
  buttonText: 'Show me something',
  onClick: () => {
    alert('Here it is!')
  }
}

Example with side effect

Code
javascript
{
  model: {
    checkboxExample: false
  },
  schema: {
    fields: [
      {
        type: 'input',
        inputType: 'checkbox',
        model: 'checkboxExample'
      },
      {
        type: 'button',
        buttonText: 'Magically check the box',
        onClick: (model, field) => {
          model.checkboxExample = true
          field.buttonText = 'Wow! Incredible!'
        }
      }
    ]
  }
}

Properties

PropertyDefaultTypeDescription
buttonText``StringText to display on the button
buttonClasses``StringString of classes to add to the button
onClick-FunctionFunction to execute when clicked, gets passed model and field as arguments