优化后台表单

This commit is contained in:
pushuo 2022-08-11 09:20:10 +08:00
parent 5bb0fb7e61
commit 68b596bbbe
8 changed files with 43 additions and 14 deletions

View File

@ -9,12 +9,14 @@ class Input extends Component
public string $name;
public string $title;
public string $value;
public bool $required;
public function __construct(string $name, string $title, ?string $value)
public function __construct(string $name, string $title, ?string $value, bool $required = false)
{
$this->name = $name;
$this->title = $title;
$this->value = $value ?? '';
$this->required = $required ?? false;
}
public function render()

View File

@ -317,6 +317,14 @@
width: 100px;
}
.col-form-label.required::before {
content: "*";
color: #f56c6c;
font-size: 12px;
font-weight: bold;
margin-right: 5px;
}
.help-text {
color: #B2B2B2;
margin-top: 4px;

View File

@ -338,6 +338,14 @@ body[class^=page-account-] {
width: 100px;
}
.col-form-label.required::before {
content: "*";
color: #f56c6c;
font-size: 12px;
font-weight: bold;
margin-right: 5px;
}
.module-title {
font-size: 1.5rem;
text-align: center;

View File

@ -67,6 +67,16 @@
}
}
.col-form-label.required {
&::before {
content: "*";
color: #f56c6c;
font-size: 12px;
font-weight: bold;
margin-right: 5px;
}
}
.help-text {
color: #B2B2B2;
margin-top: 4px;

View File

@ -1,4 +1,4 @@
<x-admin::form.row :title="$title">
<x-admin::form.row :title="$title" :required="$required">
<input type="text" name="{{ $name }}" class="form-control wp-400" value="{{ $value }}" placeholder="{{ $title }}">
{{ $slot }}
</x-admin::form.row>

View File

@ -1,15 +1,6 @@
<div class="row g-3 mb-3">
<label for="" class="wp-200 col-form-label text-end">{{ $title ?? '' }}</label>
<label for="" class="wp-200 col-form-label text-end {{ isset($required) && $required ? 'required' : '' }}">{{ $title ?? '' }}</label>
<div class="col-auto wp-200-">
{{ $slot }}
</div>
</div>
@if (0)
<div class="el-form-item el-form-item--small">
<label for="" class="el-form-item__label" style="width: 200px">{{ $title ?? '' }}</label>
<div class="el-form-item__content" style="margin-left: 200px">
{{ $slot }}
</div>
</div>
@endif
</div>

View File

@ -37,7 +37,7 @@
<div class="help-text font-size-12 lh-base">默认货币设置</div>
</x-admin-form-select>
<x-admin-form-input name="admin_name" title="后台目录" value="{{ old('admin_name', system_setting('base.admin_name', 'admin')) }}">
<x-admin-form-input name="admin_name" title="后台目录" required value="{{ old('admin_name', system_setting('base.admin_name', 'admin')) }}">
<div class="help-text font-size-12 lh-base">管理后台目录,默认为admin</div>
</x-admin-form-input>

View File

@ -67,6 +67,16 @@ body[class^="page-account-"] {
}
}
.col-form-label.required {
&::before {
content: "*";
color: #f56c6c;
font-size: 12px;
font-weight: bold;
margin-right: 5px;
}
}
.module-title {
font-size: 1.5rem;
text-align: center;