初始化仓库
This commit is contained in:
54
admin/components/UI/Form/Row.php
Normal file
54
admin/components/UI/Form/Row.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace admin\components\UI\Form;
|
||||
|
||||
use admin\components\UI\Form;
|
||||
|
||||
/**
|
||||
* Class Row
|
||||
* @package backend\components\UI\Table
|
||||
*/
|
||||
class Row extends Composite implements Component
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置列
|
||||
* @param callable $callback
|
||||
* @param int $width
|
||||
* @return $this
|
||||
*/
|
||||
public function column(callable $callback, int $width = 0): self
|
||||
{
|
||||
$form = new Form();
|
||||
$callback($form);
|
||||
$this->column[] = [
|
||||
'width' => $width,
|
||||
'object' => $form,
|
||||
];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function render(): array
|
||||
{
|
||||
$inner = [];
|
||||
foreach ($this->column as $vo) {
|
||||
$width = $vo['width'] ? "lg:row-span-{$vo['width']}" : '';
|
||||
$form = $vo['object']->renderForm();
|
||||
$inner[] = [
|
||||
'nodeName' => 'div',
|
||||
'class' => $width,
|
||||
'child' => $form
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'nodeName' => 'div',
|
||||
'class' => 'grid lg:grid-flow-col gap-4',
|
||||
'child' => $inner
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user