Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 2.15 KB

File metadata and controls

63 lines (44 loc) · 2.15 KB

ButtonGroup

ButtonGroup renders a button group widget.

Basic Usage

Instantiate the ButtonGroup class using ButtonGroup::widget().

$buttonGroup = ButtonGroup::widget();

Buttons

Add buttons to the ButtonGroup widget using the buttons method.

$buttonGroup->buttons(
    Submit::widget(),
    Reset::widget(),
);

Rendering

Generate the HTML output using the render method, for simple instantiation.

$html = $buttonGroup->render();

Or, use the magic __toString method.

$html = (string) $buttonGroup;

Common use cases

Below are examples of common use cases:

// adding multiple attributes
$buttonGroup->container()->containerClass('MyClass');

Custom methods

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.