# Button group

Button group field renders a set of buttons. It's a single-choice field, much like the [Radio field](/fields/radio.md). Supports initial [`checked` or `disabled` attributes](#checked-and-disabled).

## Example configuration

```php
...
array(
    'title' => 'My button group title',
    'id' => 'button-group-option',
    'desc' => 'Short description for the field',
    'place' => array(
        'page' => 'my-options-page',
        'tab' => 'main',
    ),
    'type' => 'button_group',
    'choices' => ['First label', 'Second label', 'Third label']
),
...
```

This will produce the following

![](/files/3wKOkuWFLcIs6N9HhNCX)

It will use the label text as the value. If you wish to separate values from labels use the following syntax for the `choices` key:

```php
...
'choices' => array(
    array(
        'value' => 'First value',
        'label' => 'First label',
    ),
    array(
        'value' => 'Second value',
        'label' => 'Second label',
    ),
    array(
        'value' => 'Third value',
        'label' => 'Third label',
    ),
)
...
```

## `checked` and `disabled`

If `checked` or `disabled` keys are specified, they'll be respected. E.g:

```php
...
'choices' => array(
    array(
        'value' => 'First value',
        'label' => 'First label',
    ),
    array(
        'value' => 'Second value',
        'label' => 'Second label',
        'checked' => true,
    ),
    array(
        'value' => 'Third value',
        'label' => 'Third label',
        'disabled' => true,
    ),
)
...
```

will result in the following

![](/files/-LKMTn1yKD-pGl5sfCSI)

Notice that the second option is checked on initial page load and the third option is not clickable.

## Params

| Name      | Type   | Description                                                                                                                                                                                                    |
| --------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`    | string | `button-group` **(required)**                                                                                                                                                                                  |
| `id`      | string | Unique ID that will be used to retrieve the value **(required)**                                                                                                                                               |
| `place`   | array  | Specifies where (page and tab) this option will be rendered                                                                                                                                                    |
| `title`   | string | Shows a heading to the left of the field                                                                                                                                                                       |
| `desc`    | string | Shows a description text (can have HTML)                                                                                                                                                                       |
| `choices` | array  | Kind of required, but will not render anything if no radio choices are provided. Can be an array of strings or an array of arrays with `value` and `label` keys. See [examples](#example-configuration) above. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alchemy-options.com/fields/button-group.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
