update:更新form功能

This commit is contained in:
JaguarJack
2021-03-29 19:51:41 +08:00
parent 114387d030
commit 2f25a0892e
4 changed files with 69 additions and 26 deletions

View File

@@ -14,29 +14,36 @@
namespace catcher\library\form;
trait FormOptions
class FormOptions
{
protected $options = [];
/**
* 是/否的选项
* 增加 option
*
* @time 2021年03月06
* @param array $label
* @param array $value
* @return array[]
* @time 2021年03月24
* @param $label
* @param $value
* @return $this
*/
protected function yesOrNo(array $label = [], array $value = []): array
public function add($label, $value): FormOptions
{
if (!count($label)) {
$label = ['是', '否'];
}
if (!count($value)) {
$value = [1, 2];
}
return [
['value' => $value[0], 'label' => $label[0]],
['value' => $value[1], 'label' => $label[1]],
$this->options[] = [
'value' => $value,
'label' => $label,
];
return $this;
}
/**
* 获取
*
* @time 2021年03月24日
* @return array
*/
public function render()
{
return $this->options;
}
}