0 follower

Final Class Yiisoft\Yii\Bulma\Modal

InheritanceYiisoft\Yii\Bulma\Modal » Yiisoft\Widget\Widget

Modal renders a modal window that can be toggled by clicking on a button.

The following example will show the content enclosed between the {@see \Yiisoft\Widget\Widget::begin()} and {@see \Yiisoft\Widget\Widget::end()} calls within the modal window:

echo Modal::widget()->begin();

echo 'Say hello...';

echo Modal::end();

Public Methods

Hide inherited methods

Method Description Defined By
attributes() Returns a new instance with the specified HTML attributes for widget. Yiisoft\Yii\Bulma\Modal
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\Modal
backgroundClass() Returns a new instance with the specified modal background class. Yiisoft\Yii\Bulma\Modal
begin() Yiisoft\Yii\Bulma\Modal
buttonClass() Returns a new instance with the specified modal button class. Yiisoft\Yii\Bulma\Modal
closeButtonAttributes() Returns a new instance with the specified close button options. Yiisoft\Yii\Bulma\Modal
closeButtonSize() Returns a new instance with the specified close button size. Yiisoft\Yii\Bulma\Modal
contentAttributes() Returns a new instance with the specified content options. Yiisoft\Yii\Bulma\Modal
contentClass() Returns a new instance with the specified modal content class. Yiisoft\Yii\Bulma\Modal
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\Modal
modalClass() Returns a new instance with the specified modal class. Yiisoft\Yii\Bulma\Modal
render() Yiisoft\Yii\Bulma\Modal
toggleButtonAttributes() Returns a new instance with the specified toggle button options. Yiisoft\Yii\Bulma\Modal
toggleButtonColor() Returns a new instance with the specified toggle button color. Yiisoft\Yii\Bulma\Modal
toggleButtonLabel() Returns a new instance with the specified toggle button label. Yiisoft\Yii\Bulma\Modal
toggleButtonSize() Returns a new instance with the specified toggle button size. Yiisoft\Yii\Bulma\Modal
withoutCloseButton() Returns a new instance with the specified options for rendering the close button tag. Yiisoft\Yii\Bulma\Modal
withoutToggleButton() Returns a new instance with the disabled toggle button. Yiisoft\Yii\Bulma\Modal

Constants

Hide inherited constants

Constant Value Description Defined By
COLOR_ALL [ self::COLOR_PRIMARY, self::COLOR_LINK, self::COLOR_INFO, self::COLOR_SUCCESS, self::COLOR_WARNING, self::COLOR_DANGER, self::COLOR_DARK, ] Yiisoft\Yii\Bulma\Modal
COLOR_DANGER 'is-danger' Yiisoft\Yii\Bulma\Modal
COLOR_DARK 'is-dark' Yiisoft\Yii\Bulma\Modal
COLOR_INFO 'is-info' Yiisoft\Yii\Bulma\Modal
COLOR_PRIMARY 'is-primary' Yiisoft\Yii\Bulma\Modal
COLOR_SUCCESS 'is-success' Yiisoft\Yii\Bulma\Modal
COLOR_WARNING 'is-warning' Yiisoft\Yii\Bulma\Modal
SIZE_ALL [ self::SIZE_SMALL, self::SIZE_MEDIUM, self::SIZE_LARGE, ] Yiisoft\Yii\Bulma\Modal
SIZE_LARGE 'is-large' Yiisoft\Yii\Bulma\Modal
SIZE_MEDIUM 'is-medium' Yiisoft\Yii\Bulma\Modal
SIZE_SMALL 'is-small' Yiisoft\Yii\Bulma\Modal

Method Details

Hide inherited methods

attributes() public method

Returns a new instance with the specified HTML attributes for widget.

public self attributes ( array $values )
$values array

Attribute values indexed by attribute names.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function attributes(array $values): self
{
    $new = clone $this;
    $new->attributes = $values;
    return $new;
}

            
autoIdPrefix() public method

Returns a new instance with the specified prefix to the automatically generated widget IDs.

public self autoIdPrefix ( string $value )
$value string

The prefix to the automatically generated widget IDs.

                public function autoIdPrefix(string $value): self
{
    $new = clone $this;
    $new->autoIdPrefix = $value;
    return $new;
}

            
backgroundClass() public method

Returns a new instance with the specified modal background class.

public self backgroundClass ( string $value )
$value string

The modal background class.

                public function backgroundClass(string $value): self
{
    $new = clone $this;
    $new->backgroundClass = $value;
    return $new;
}

            
begin() public method

public string|null begin ( )

                public function begin(): ?string
{
    parent::begin();
    $attributes = $this->attributes;
    $contentAttributes = $this->contentAttributes;
    $html = '';
    if (!array_key_exists('id', $attributes)) {
        $attributes['id'] = Html::generateId($this->autoIdPrefix) . '-modal';
    }
    /** @var string */
    $id = $attributes['id'];
    Html::addCssClass($attributes, $this->modalClass);
    Html::addCssClass($contentAttributes, $this->contentClass);
    if ($this->withoutToggleButton === false) {
        $html = $this->renderToggleButton($id) . PHP_EOL;
    }
    $html .= Html::openTag('div', $attributes) . PHP_EOL; // .modal
    $html .= Div::tag()->class($this->backgroundClass) . PHP_EOL;
    if ($this->withoutCloseButton === false) {
        $html .= $this->renderCloseButton() . PHP_EOL;
    }
    $html .= Html::openTag('div', $contentAttributes) . PHP_EOL; // .modal-content
    return $html;
}

            
buttonClass() public method

Returns a new instance with the specified modal button class.

public self buttonClass ( string $value )
$value string

The modal button class.

                public function buttonClass(string $value): self
{
    $new = clone $this;
    $new->buttonClass = $value;
    return $new;
}

            
closeButtonAttributes() public method

Returns a new instance with the specified close button options.

public self closeButtonAttributes ( array $value )
$value array

The close button options.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function closeButtonAttributes(array $value): self
{
    $new = clone $this;
    $new->closeButtonAttributes = $value;
    return $new;
}

            
closeButtonSize() public method

Returns a new instance with the specified close button size.

public self closeButtonSize ( string $value )
$value string

The close button size. Default setting empty normal. Possible values: Modal::SIZE_SMALL, Modal::SIZE_MEDIUM, Model::SIZE_LARGE.

                public function closeButtonSize(string $value): self
{
    if (!in_array($value, self::SIZE_ALL, true)) {
        $values = implode('", "', self::SIZE_ALL);
        throw new InvalidArgumentException("Invalid size. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->closeButtonSize = $value;
    return $new;
}

            
contentAttributes() public method

Returns a new instance with the specified content options.

public self contentAttributes ( array $value )
$value array

The content options.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function contentAttributes(array $value): self
{
    $new = clone $this;
    $new->contentAttributes = $value;
    return $new;
}

            
contentClass() public method

Returns a new instance with the specified modal content class.

public self contentClass ( string $value )
$value string

The modal content class.

                public function contentClass(string $value): self
{
    $new = clone $this;
    $new->contentClass = $value;
    return $new;
}

            
id() public method

Returns a new instance with the specified ID of the widget.

public self id ( string $value )
$value string

The ID of the widget.

                public function id(string $value): self
{
    $new = clone $this;
    $new->attributes['id'] = $value;
    return $new;
}

            
modalClass() public method

Returns a new instance with the specified modal class.

public self modalClass ( string $value )
$value string

The modal class.

                public function modalClass(string $value): self
{
    $new = clone $this;
    $new->modalClass = $value;
    return $new;
}

            
render() public method

public string render ( )

                public function render(): string
{
    $html = Html::closeTag('div') . PHP_EOL; // .modal-content
    $html .= Html::closeTag('div'); // .modal
    return $html;
}

            
toggleButtonAttributes() public method

Returns a new instance with the specified toggle button options.

public self toggleButtonAttributes ( array $values )
$values array

Attribute values indexed by attribute names.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function toggleButtonAttributes(array $values): self
{
    $new = clone $this;
    $new->toggleButtonAttributes = $values;
    return $new;
}

            
toggleButtonColor() public method

Returns a new instance with the specified toggle button color.

public self toggleButtonColor ( string $value )
$value string

The toggle button color. Default setting is empty without color. Possible values: Modal::COLOR_PRIMARY, Modal::COLOR_LINK, Modal::COLOR_INFO, Modal::COLOR_SUCCESS, Modal::COLOR_WARNING, Modal::COLOR_DANGER, Modal::COLOR_DARK.

                public function toggleButtonColor(string $value): self
{
    if (!in_array($value, self::COLOR_ALL, true)) {
        $values = implode('", "', self::COLOR_ALL);
        throw new InvalidArgumentException("Invalid color. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->toggleButtonColor = $value;
    return $new;
}

            
toggleButtonLabel() public method

Returns a new instance with the specified toggle button label.

public self toggleButtonLabel ( string $value )
$value string

The toggle button label.

                public function toggleButtonLabel(string $value): self
{
    $new = clone $this;
    $new->toggleButtonLabel = $value;
    return $new;
}

            
toggleButtonSize() public method

Returns a new instance with the specified toggle button size.

public self toggleButtonSize ( string $value )
$value string

The toggle button size. Default setting empty normal. Possible values: Modal::SIZE_SMALL, Modal::SIZE_MEDIUM, Model::SIZE_LARGE.

                public function toggleButtonSize(string $value): self
{
    if (!in_array($value, self::SIZE_ALL, true)) {
        $values = implode('", "', self::SIZE_ALL);
        throw new InvalidArgumentException("Invalid size. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->toggleButtonSize = $value;
    return $new;
}

            
withoutCloseButton() public method

Returns a new instance with the specified options for rendering the close button tag.

public self withoutCloseButton ( boolean $value )
$value boolean

Whether the close button is disabled.

                public function withoutCloseButton(bool $value): self
{
    $new = clone $this;
    $new->withoutCloseButton = $value;
    return $new;
}

            
withoutToggleButton() public method

Returns a new instance with the disabled toggle button.

public self withoutToggleButton ( boolean $value )
$value boolean

Whether the toggle button is disabled.

                public function withoutToggleButton(bool $value): self
{
    $new = clone $this;
    $new->withoutToggleButton = $value;
    return $new;
}