From 5ce104e82050e47241e575861876d88defefa825 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 31 Mar 2021 20:21:02 +0800 Subject: [PATCH] =?UTF-8?q?update:form=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/library/form/Form.php | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/extend/catcher/library/form/Form.php b/extend/catcher/library/form/Form.php index a3181b9..aa9ca90 100644 --- a/extend/catcher/library/form/Form.php +++ b/extend/catcher/library/form/Form.php @@ -261,4 +261,60 @@ abstract class Form { return new FormOptions(); } + + /** + * props + * + * @time 2021年03月30日 + * @param $label + * @param string $value + * @param array $extra + * @param array $data + * @return array + */ + public static function props($label, $value = 'id', array $extra = [], array $data = []): array + { + $props = [ + 'props' => array_merge([ + 'label' => $label, + 'value' => $value, + ], $extra) + ]; + + if (count($data)) { + $props['data'] = $data; + } + + return $props; + } + + /** + * 不需要 props + * + * @time 2021年03月30日 + * @param $label + * @param string $value + * @param array $extra + * @return array + */ + public static function treeProps($label, $value = 'id', array $extra = []): array + { + return array_merge([ + 'label' => $label, + 'value' => $value, + ], $extra); + } + + /** + * col + * + * @time 2021年03月30日 + * @param int $col + * @return array + */ + public static function col(int $col): array + { + return ['span' => $col]; + } + }