-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* @link https://craftcms.com/ | ||
* @copyright Copyright (c) Pixel & Tonic, Inc. | ||
* @license https://craftcms.github.io/license/ | ||
*/ | ||
|
||
namespace craft\fieldlayoutelements; | ||
|
||
use craft\base\ElementInterface; | ||
use craft\base\FieldLayoutElement; | ||
use craft\helpers\Html as HtmlHelper; | ||
use yii\base\NotSupportedException; | ||
|
||
/** | ||
* Html represents a field layout component that displays arbitrary HTML. | ||
* | ||
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com> | ||
* @since 3.5.0 | ||
*/ | ||
class Html extends FieldLayoutElement | ||
{ | ||
private string $html; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct(string $html, array $config = []) | ||
{ | ||
$this->html = $html; | ||
parent::__construct($config); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* @throws NotSupportedException | ||
*/ | ||
public function selectorHtml(): string | ||
{ | ||
throw new NotSupportedException(sprintf('%s should not be included in user-modifyable field layouts.', __CLASS__)); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function formHtml(?ElementInterface $element = null, bool $static = false): ?string | ||
{ | ||
return HtmlHelper::tag('div', $this->html); | ||
} | ||
} |