widget/WidgetHelper.php
public static function mergeAttributes(Field $field, $attrs = null)
    {
        $attributes = $field->getAttributes();
        if (is_array($attrs)) {
            foreach ($attrs as $key => $val) {
                $key = Utils::camelToAttr($key);
                if ($key[0] == '@') {
                    continue;
                }
                $attributes[$key] = $val;
            }
        }
        $base = [];
        // Logger::log($attributes);
        /*
        if (isset($attributes['data-dynamic'])) {
            if (!isset($attributes['yee-module'])) {
                $attributes['yee-module'] = 'dynamic';
            } else {
                $attributes['yee-module'] .= ' dynamic';
            }
        }*/
        foreach ($attributes as $name => $val) {
            if ($val === null || $val === '') {
                continue;
            }
            if ($name == 'data-val') {
                $name = 'data-v@rule';
            } //验证数据
            else if (preg_match('@^data-val-(.*)$@', $name, $m)) {
                $name = 'data-v@' . $m[1];
            }
            if (is_array($val)) {
                array_push($base, $name . '="' . htmlspecialchars(json_encode($val, JSON_UNESCAPED_UNICODE)) . '"');
            } else if (is_bool($val)) {
                array_push($base, $name . '="' . ($val ? 1 : 0) . '"');
            } else if (is_string($val)) {
                array_push($base, $name . '="' . htmlspecialchars($val) . '"');
            } else {
                array_push($base, $name . '="' . $val . '"');
            }
        }
        return $base;
    }
public static function mergeAttributes(Field $field, $attrs = null)
    {
        $attributes = $field->getAttributes();
        if (is_array($attrs)) {
            foreach ($attrs as $key => $val) {
                $key = Utils::camelToAttr($key);
                if ($key[0] == '@') {
                    continue;
                }
                $attributes[$key] = $val;
            }
        }
        $base = [];
        // Logger::log($attributes);
        /*
        if (isset($attributes['data-dynamic'])) {
            if (!isset($attributes['yee-module'])) {
                $attributes['yee-module'] = 'dynamic';
            } else {
                $attributes['yee-module'] .= ' dynamic';
            }
        }*/
        foreach ($attributes as $name => $val) {
            if ($val === null || $val === '') {
                continue;
            }
            if ($name == 'data-val') {
                $name = 'data-v@rule';
            } //验证数据
            else if (preg_match('@^data-val-(.*)$@', $name, $m)) {
                $name = 'data-v@' . $m[1];
            }
            if (is_array($val)) {
                array_push($base, $name . '="' . htmlspecialchars(json_encode($val, JSON_UNESCAPED_UNICODE)) . '"');
            } else if (is_bool($val)) {
                array_push($base, $name . '="' . ($val ? 1 : 0) . '"');
            } else if (is_string($val)) {
                array_push($base, $name . '="' . htmlspecialchars($val) . '"');
            } else {
                array_push($base, $name . '="' . $val . '"');
            }
        }
        return $base;
    }
合并属性
@param Field $field
@param array $attrs
@return array