ButtonGroup renders a button group widget.
Instantiate the ButtonGroup class using ButtonGroup::widget().
$buttonGroup = ButtonGroup::widget();Add buttons to the ButtonGroup widget using the buttons method.
$buttonGroup->buttons(
Submit::widget(),
Reset::widget(),
);Generate the HTML output using the render method, for simple instantiation.
$html = $buttonGroup->render();Or, use the magic __toString method.
$html = (string) $buttonGroup;Below are examples of common use cases:
// adding multiple attributes
$buttonGroup->container()->containerClass('MyClass');Refer to the Custom Methods Tests for comprehensive examples.
The following methods are available for customizing the HTML output:
| Method | Description |
|---|---|
buttons() |
Set the button for the ButtonGroup widget. |
container() |
Set enabled or disabled for the container element. |
containerAttributes() |
Set attributes for the container element. |
containerClass() |
Set the class attribute for the container element. |
containerTag() |
Set the tag for the container element. |
individualContainer() |
Set enabled or disabled for the individualContainer for each button. |
render() |
Generates the HTML output. |
widget() |
Instantiates the ButtonGroup::class. |