fix #1173
This commit is contained in:
@@ -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;
|
||||
|
||||
/**
|
||||
* 设置表单元素值
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user