Final Class Yiisoft\Yii\Bulma\ModalCard
| Inheritance | Yiisoft\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
| 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
| 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_LINK | 'is-link' | 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
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;
}
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;
}
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;
}
| 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
| 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
Signup or Login in order to comment.