0 follower

Final Class Yiisoft\Yii\Bulma\ModalCard

InheritanceYiisoft\Yii\Bulma\ModalCard » Yiisoft\Widget\Widget

ModalCard 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 ModalCard::widget()
    ->title('Modal title')
    ->footer(
        Html::button('Cancel', ['class' => 'button'])
    )
    ->begin();

echo 'Say hello...';

echo ModalCard::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\ModalCard
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\ModalCard
backgroundClass() Returns a new instance with the specified modal card background class. Yiisoft\Yii\Bulma\ModalCard
begin() Yiisoft\Yii\Bulma\ModalCard
bodyAttributes() Returns a new instance with the specified body attributes. Yiisoft\Yii\Bulma\ModalCard
bodyClass() Returns a new instance with the specified modal card body class. Yiisoft\Yii\Bulma\ModalCard
buttonClass() Returns a new instance with the specified modal card button class. Yiisoft\Yii\Bulma\ModalCard
cardAttributes() Returns a new instance with the specified card attributes. Yiisoft\Yii\Bulma\ModalCard
cardClass() Returns a new instance with the specified modal card class. Yiisoft\Yii\Bulma\ModalCard
closeButtonAttributes() Returns a new instance with the specified close button attributes. Yiisoft\Yii\Bulma\ModalCard
closeButtonCssClass() Returns a new instance with the specified close button class. Yiisoft\Yii\Bulma\ModalCard
closeButtonSize() Returns a new instance with the specified close button size. Yiisoft\Yii\Bulma\ModalCard
contentClass() Returns a new instance with the specified modal card content class. Yiisoft\Yii\Bulma\ModalCard
footer() Returns a new instance with the specified footer content. Yiisoft\Yii\Bulma\ModalCard
footerAttributes() Returns a new instance with the specified footer attributes. Yiisoft\Yii\Bulma\ModalCard
footerClass() Returns a new instance with the specified modal card footer class. Yiisoft\Yii\Bulma\ModalCard
headerAttributes() Returns a new instance with the specified header attributes. Yiisoft\Yii\Bulma\ModalCard
headerClass() Returns a new instance with the specified modal card header class. Yiisoft\Yii\Bulma\ModalCard
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\ModalCard
render() Yiisoft\Yii\Bulma\ModalCard
title() Returns a new instance with the specified title content. Yiisoft\Yii\Bulma\ModalCard
titleAttributes() Returns a new instance with the specified title attributes. Yiisoft\Yii\Bulma\ModalCard
titleClass() Returns a new instance with the specified modal card title class. Yiisoft\Yii\Bulma\ModalCard
toggleButtonAttributes() Returns a new instance with the specified toggle button attributes. Yiisoft\Yii\Bulma\ModalCard
toggleButtonColor() Returns a new instance with the specified toggle button color. Yiisoft\Yii\Bulma\ModalCard
toggleButtonId() Returns a new instance with the specified ID of the toggle button. Yiisoft\Yii\Bulma\ModalCard
toggleButtonLabel() Returns a new instance with the specified toggle button label. Yiisoft\Yii\Bulma\ModalCard
toggleButtonSize() Returns a new instance with the specified toggle button size. Yiisoft\Yii\Bulma\ModalCard
withoutCloseButton() Returns a new instance with the specified options for rendering the close button tag. Yiisoft\Yii\Bulma\ModalCard
withoutToggleButton() Returns a new instance with the disabled toggle button. Yiisoft\Yii\Bulma\ModalCard

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\ModalCard
COLOR_DANGER 'is-danger' Yiisoft\Yii\Bulma\ModalCard
COLOR_DARK 'is-dark' Yiisoft\Yii\Bulma\ModalCard
COLOR_INFO 'is-info' Yiisoft\Yii\Bulma\ModalCard
COLOR_PRIMARY 'is-primary' Yiisoft\Yii\Bulma\ModalCard
COLOR_SUCCESS 'is-success' Yiisoft\Yii\Bulma\ModalCard
COLOR_WARNING 'is-warning' Yiisoft\Yii\Bulma\ModalCard
SIZE_ALL [ self::SIZE_SMALL, self::SIZE_MEDIUM, self::SIZE_LARGE, ] Yiisoft\Yii\Bulma\ModalCard
SIZE_LARGE 'is-large' Yiisoft\Yii\Bulma\ModalCard
SIZE_MEDIUM 'is-medium' Yiisoft\Yii\Bulma\ModalCard
SIZE_SMALL 'is-small' Yiisoft\Yii\Bulma\ModalCard

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 card background class.

public self backgroundClass ( string $value )
$value string

The modal card 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;
    $cardAttributes = $this->cardAttributes;
    $html = '';
    if (!array_key_exists('id', $attributes)) {
        $attributes['id'] = Html::generateId($this->autoIdPrefix) . '-modal';
    }
    /** @var string */
    $id = $attributes['id'];
    if ($this->withoutToggleButton === false) {
        $html .= $this->renderToggleButton($id) . "\n";
    }
    Html::addCssClass($attributes, $this->cardClass);
    Html::addCssClass($cardAttributes, $this->contentClass);
    $html .= Html::openTag('div', $attributes) . "\n"; // .modal
    $html .= $this->renderBackgroundTransparentOverlay() . "\n"; // .modal-background
    $html .= Html::openTag('div', $cardAttributes) . "\n"; // .modal-card
    $html .= $this->renderHeader();
    $html .= $this->renderBodyBegin() . "\n";
    return $html;
}

            
bodyAttributes() public method

Returns a new instance with the specified body attributes.

public self bodyAttributes ( array $value )
$value array

The body attributes.

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

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

            
bodyClass() public method

Returns a new instance with the specified modal card body class.

public self bodyClass ( string $value )
$value string

The modal card body class.

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

            
buttonClass() public method

Returns a new instance with the specified modal card button class.

public self buttonClass ( string $value )
$value string

The modal card button class.

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

            
cardAttributes() public method

Returns a new instance with the specified card attributes.

public self cardAttributes ( array $value )
$value array

The content attributes.

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

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

            
cardClass() public method

Returns a new instance with the specified modal card class.

public self cardClass ( string $value )
$value string

The modal card class.

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

            
closeButtonAttributes() public method

Returns a new instance with the specified close button attributes.

public self closeButtonAttributes ( array $value )
$value array

The close button attributes.

{@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;
}

            
closeButtonCssClass() public method

Returns a new instance with the specified close button class.

public self closeButtonCssClass ( string $value )
$value string

The close button class.

                public function closeButtonCssClass(string $value): self
{
    $new = clone $this;
    $new->closeButtonCssClass = $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 is "normal". Possible values are: ModalCard::SIZE_SMALL, ModalCard::SIZE_MEDIUM, ModalCard::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;
}

            
contentClass() public method

Returns a new instance with the specified modal card content class.

public self contentClass ( string $value )
$value string

The modal card content class.

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

            
footer() public method

Returns a new instance with the specified footer content.

public self footer ( string $value )
$value string

The footer content in the modal window.

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

            
footerAttributes() public method

Returns a new instance with the specified footer attributes.

public self footerAttributes ( array $value )
$value array

The footer attributes.

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

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

            
footerClass() public method

Returns a new instance with the specified modal card footer class.

public self footerClass ( string $value )
$value string

The modal card footer class.

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

            
headerAttributes() public method

Returns a new instance with the specified header attributes.

public self headerAttributes ( array $value )
$value array

The header attributes.

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

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

            
headerClass() public method

Returns a new instance with the specified modal card header class.

public self headerClass ( string $value )
$value string

The modal card head class.

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

            
id() public method

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

public self id ( string|null $value )
$value string|null

The ID of the widget.

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

            
render() public method

public string render ( )

                public function render(): string
{
    $html = $this->renderBodyEnd() . "\n";
    $html .= $this->renderFooter() . "\n";
    $html .= Html::closeTag('div') . "\n"; // .modal-card
    $html .= Html::closeTag('div'); // .modal
    return $html;
}

            
title() public method

Returns a new instance with the specified title content.

public self title ( string $value )
$value string

The title content in the modal window.

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

            
titleAttributes() public method

Returns a new instance with the specified title attributes.

public self titleAttributes ( array $value )
$value array

The title attributes.

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

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

            
titleClass() public method

Returns a new instance with the specified modal card title class.

public self titleClass ( string $value )
$value string

The modal card title class.

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

            
toggleButtonAttributes() public method

Returns a new instance with the specified toggle button attributes.

public self toggleButtonAttributes ( array $value )
$value array

The toggle button attributes.

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

                public function toggleButtonAttributes(array $value): self
{
    $new = clone $this;
    $new->toggleButtonAttributes = $value;
    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. By default, there's no color set. Possible values are: ModalCard::COLOR_PRIMARY, ModalCard::COLOR_INFO, ModalCard::COLOR_SUCCESS, ModalCard::COLOR_WARNING, ModalCard::COLOR_DANGER, ModalCard::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;
}

            
toggleButtonId() public method

Returns a new instance with the specified ID of the toggle button.

public self toggleButtonId ( string|null $value )
$value string|null

The ID of the widget.

                public function toggleButtonId(?string $value): self
{
    $new = clone $this;
    $new->toggleButtonAttributes['id'] = $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.

                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;
}