Final Class Yiisoft\Yii\Bulma\Modal
| Inheritance | Yiisoft\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
| 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
| 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_LINK | 'is-link' | 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
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 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;
}
| 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
| public string render ( ) |
public function render(): string
{
$html = Html::closeTag('div') . PHP_EOL; // .modal-content
$html .= Html::closeTag('div'); // .modal
return $html;
}
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;
}
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;
}
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. 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;
}
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.