* Fix bug#43295.
This commit is contained in:
+17
-2
@@ -213,7 +213,7 @@ class form extends fixer
|
||||
if(isset($config['filter'])) $rowData->$field = $this->filter($rowData->$field, $config['filter']);
|
||||
|
||||
/* 检查必填字段。Check required fields. */
|
||||
if(isset($config['required']) && $config['required'] && !isset($rowData->$field))
|
||||
if(isset($config['required']) && $config['required'] && $this->checkEmpty($rowData->$field))
|
||||
{
|
||||
$errorKey = isset($config['type']) && $config['type'] == 'array' ? "{$field}[{$rowIndex}][]" : "{$field}[{$rowIndex}]";
|
||||
$fieldName = isset($app->lang->{$app->rawModule}->$field) ? $app->lang->{$app->rawModule}->$field : $field;
|
||||
@@ -228,6 +228,21 @@ class form extends fixer
|
||||
$this->dataList = $rowDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查为空。
|
||||
* Empty checking.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return bool
|
||||
*/
|
||||
public function checkEmpty(mixed $data): bool
|
||||
{
|
||||
if(is_array($data)) return empty($data);
|
||||
|
||||
$data = (string)$data;
|
||||
return empty(strlen($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取$_POST的数据。
|
||||
* Get the data of $_POST.
|
||||
@@ -267,7 +282,7 @@ class form extends fixer
|
||||
|
||||
if(isset($config['filter'])) $data = $this->filter($data, $config['filter']);
|
||||
|
||||
if(isset($config['required']) && $config['required'] && !isset($data))
|
||||
if(isset($config['required']) && $config['required'] && $this->checkEmpty($data))
|
||||
{
|
||||
$errorKey = isset($config['type']) && $config['type'] == 'array' ? "{$field}[]" : $field;
|
||||
$fieldName = isset($app->lang->{$app->rawModule}->$field) ? $app->lang->{$app->rawModule}->$field : $field;
|
||||
|
||||
Reference in New Issue
Block a user