Class yii\bootstrap\Progress

Inheritanceyii\bootstrap\Progress » yii\bootstrap\Widget » yii\base\Widget
Uses Traitsyii\bootstrap\BootstrapWidgetTrait
Available since version2.0

Progress renders a bootstrap progress bar component.

For example,

// default with label
echo Progress::widget([
    'percent' => 60,
    'label' => 'test',
]);

// styled
echo Progress::widget([
    'percent' => 65,
    'options' => ['class' => 'progress-danger']
]);

// striped
echo Progress::widget([
    'percent' => 70,
    'options' => ['class' => 'progress-warning progress-striped']
]);

// striped animated
echo Progress::widget([
    'percent' => 70,
    'options' => ['class' => 'progress-success active progress-striped']
]);

// stacked bars
echo Progress::widget([
    'bars' => [
        ['percent' => 30, 'options' => ['class' => 'progress-danger']],
        ['percent' => 30, 'label' => 'test', 'options' => ['class' => 'progress-success']],
        ['percent' => 35, 'options' => ['class' => 'progress-warning']],
    ]
]);

See also http://getbootstrap.com/components/#progress.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$bars array A set of bars that are stacked together to form a single progress bar. yii\bootstrap\Progress
$clientEvents array The event handlers for the underlying Bootstrap JS plugin. yii\bootstrap\BootstrapWidgetTrait
$clientOptions array The options for the underlying Bootstrap JS plugin. yii\bootstrap\BootstrapWidgetTrait
$label string The button label. yii\bootstrap\Progress
$options array The HTML attributes for the widget container tag. yii\bootstrap\Widget
$percent integer The amount of progress as a percentage. yii\bootstrap\Progress

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getView() yii\bootstrap\BootstrapWidgetTrait
init() Initializes the widget. yii\bootstrap\BootstrapWidgetTrait
run() Renders the widget. yii\bootstrap\Progress

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
registerClientEvents() Registers JS event handlers that are listed in $clientEvents. yii\bootstrap\BootstrapWidgetTrait
registerPlugin() Registers a specific Bootstrap plugin and the related events yii\bootstrap\BootstrapWidgetTrait
renderBar() Generates a bar yii\bootstrap\Progress
renderProgress() Renders the progress. yii\bootstrap\Progress

Property Details

$bars public property

A set of bars that are stacked together to form a single progress bar. Each bar is an array of the following structure:

[
    // required, the amount of progress as a percentage.
    'percent' => 30,
    // optional, the label to be displayed on the bar
    'label' => '30%',
    // optional, array, additional HTML attributes for the bar tag
    'options' => [],
]
public array $bars null
$label public property

The button label.

public string $label null
$percent public property

The amount of progress as a percentage.

public integer $percent 0

Method Details

renderBar() protected method

Generates a bar

protected string renderBar ( $percent, $label '', $options = [] )
$percent integer

The percentage of the bar

$label
$options array

The HTML attributes of the bar

return string

The rendering result.

renderProgress() protected method

Renders the progress.

protected string renderProgress ( )
return string

The rendering result.

throws \yii\base\InvalidConfigException

if the "percent" option is not set in a stacked progress bar.

run() public method

Renders the widget.

public void run ( )