This commit is contained in:
pushuo 2022-08-11 12:00:11 +08:00
parent 3920639f34
commit da8854a62f
3 changed files with 7 additions and 5 deletions

View File

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

View File

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

View File

@ -17,7 +17,7 @@
<x-admin-form-input
:name="$column['name']"
:title="$column['label']"
:class="$errors->has('name') ? 'is-invalid' : ''"
:class="$errors->has($column['name']) ? 'is-invalid' : ''"
:required="$column['required'] ? true : false"
:value="old($column['value'], $column['value'] ?? '')">
@if (isset($column['description']))