Files
xk-api-yii/admin/components/UI/Form/Html.php
2024-09-19 11:32:39 +08:00

41 lines
784 B
PHP

<?php
namespace admin\components\UI\Form;
/**
* 自定义Html
* @package backend\components\UI\Table
*/
class Html extends Element implements Component
{
protected \Closure $callback;
/**
* @param string $name
* @param \Closure $callback
*/
public function __construct(string $name, \Closure $callback)
{
$this->name = $name;
$this->callback = $callback;
}
/**
* @return array
*/
public function render(): array
{
$callback = is_callable($this->callback) ? call_user_func($this->callback) : $this->callback;
if (is_array($callback)) {
return $callback;
}
return [
'nodeName' => 'rich-text',
'nodes' => $callback
];
}
}