0.31.0 (latest) 0.30.0 0.29.0 0.28.0 0.27.0 0.23.0 0.20.0 0.19.0 0.18.0 0.17.1 0.16.1 0.15.0 0.14.0 0.13.1 0.12.1 0.11.2 0.10.0 0.9.0 0.8.1 0.7.2 0.6.1 0.5.0 0.4.0 0.3.0 0.2.0 0.1.4 Reference documentation and code samples for the Google Apps Chat V1 Client class SwitchControl.

Either a toggle-style switch or a checkbox inside a `decoratedText` widget.

[Google Workspace add-ons and Chat
apps](https://developers.google.com/workspace/extend):
Only supported in the `decoratedText` widget.

Generated from protobuf message `google.apps.card.v1.DecoratedText.SwitchControl`

## Namespace

Google \\ Apps \\ Card \\ V1 \\ DecoratedText

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` The name by which the switch widget is identified in a form input event. For details about working with form inputs, see [Receive form data](https://developers.google.com/workspace/chat/read-form-data). |
| `↳ value` | `string` The value entered by a user, returned as part of a form input event. For details about working with form inputs, see [Receive form data](https://developers.google.com/workspace/chat/read-form-data). |
| `↳ selected` | `bool` When `true`, the switch is selected. |
| `↳ on_change_action` | `Google\Apps\Card\V1\Action` The action to perform when the switch state is changed, such as what function to run. |
| `↳ control_type` | `int` How the switch appears in the user interface. [Google Workspace add-ons and Chat apps](https://developers.google.com/workspace/extend): |

### getName

The name by which the switch widget is identified in a form input event.

For details about working with form inputs, see [Receive form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

The name by which the switch widget is identified in a form input event.

For details about working with form inputs, see [Receive form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getValue

The value entered by a user, returned as part of a form input event.

For details about working with form inputs, see [Receive form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setValue

The value entered by a user, returned as part of a form input event.

For details about working with form inputs, see [Receive form
data](https://developers.google.com/workspace/chat/read-form-data).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSelected

When `true`, the switch is selected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setSelected

When `true`, the switch is selected.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getOnChangeAction

The action to perform when the switch state is changed, such as what
function to run.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Apps\Card\V1\Action|null` |   |

### hasOnChangeAction

### clearOnChangeAction

### setOnChangeAction

The action to perform when the switch state is changed, such as what
function to run.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `Google\Apps\Card\V1\Action` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getControlType

How the switch appears in the user interface.

[Google Workspace add-ons
and Chat apps](https://developers.google.com/workspace/extend):

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [ControlType](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.DecoratedText.SwitchControl.ControlType.md.txt). |

### setControlType

How the switch appears in the user interface.

[Google Workspace add-ons
and Chat apps](https://developers.google.com/workspace/extend):

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [ControlType](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Card.V1.DecoratedText.SwitchControl.ControlType.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |