This commit is contained in:
joyqi
2021-09-14 00:24:56 +08:00
parent 3f14d6e138
commit 5d20d57be9
10 changed files with 22 additions and 22 deletions

View File

@@ -204,9 +204,9 @@ abstract class Element extends Layout
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
abstract public function input(?string $name = null, ?array $options = null): Layout;
abstract public function input(?string $name = null, ?array $options = null): ?Layout;
/**
* 设置表单元素值

View File

@@ -31,9 +31,9 @@ class Checkbox extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
foreach ($options as $value => $label) {
$this->options[$value] = new Layout('input');
@@ -51,7 +51,7 @@ class Checkbox extends Element
$this->container($item);
}
return current($this->options);
return current($this->options) ?: null;
}
/**

View File

@@ -47,9 +47,9 @@ class Fake extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('input');
$this->inputs[] = $input;

View File

@@ -36,9 +36,9 @@ class Hidden extends Element
* @access public
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('input', ['name' => $name, 'type' => 'hidden']);
$this->container($input);

View File

@@ -24,9 +24,9 @@ class Password extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('input', ['id' => $name . '-0-' . self::$uniqueId,
'name' => $name, 'type' => 'password', 'class' => 'password']);

View File

@@ -31,9 +31,9 @@ class Radio extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
foreach ($options as $value => $label) {
$this->options[$value] = new Layout('input');
@@ -51,7 +51,7 @@ class Radio extends Element
$this->container($item);
}
return current($this->options);
return current($this->options) ?: null;
}
/**

View File

@@ -31,9 +31,9 @@ class Select extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('select');
$this->container($input->setAttribute('name', $name)

View File

@@ -24,9 +24,9 @@ class Submit extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$this->setAttribute('class', 'typecho-option typecho-option-submit');
$input = new Layout('button', ['type' => 'submit']);

View File

@@ -24,9 +24,9 @@ class Text extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('input', ['id' => $name . '-0-' . self::$uniqueId,
'name' => $name, 'type' => 'text', 'class' => 'text']);

View File

@@ -24,9 +24,9 @@ class Textarea extends Element
*
* @param string|null $name 表单元素名称
* @param array|null $options 选择项
* @return Layout
* @return Layout|null
*/
public function input(?string $name = null, ?array $options = null): Layout
public function input(?string $name = null, ?array $options = null): ?Layout
{
$input = new Layout('textarea', ['id' => $name . '-0-' . self::$uniqueId, 'name' => $name]);
$this->label->setAttribute('for', $name . '-0-' . self::$uniqueId);