mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 19:14:45 +02:00
Add required rule separately
This commit is contained in:
parent
51cd7a8e81
commit
643e4168b9
@ -371,19 +371,20 @@ class CreateServer extends CreateRecord
|
|||||||
$text = Forms\Components\TextInput::make('variable_value')
|
$text = Forms\Components\TextInput::make('variable_value')
|
||||||
->hidden($this->shouldHideComponent(...))
|
->hidden($this->shouldHideComponent(...))
|
||||||
->maxLength(191)
|
->maxLength(191)
|
||||||
->rules([
|
->required(fn (Forms\Get $get) => in_array('required', explode('|', $get('rules'))))
|
||||||
|
->rules(
|
||||||
fn (Forms\Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
|
fn (Forms\Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
|
||||||
$validator = Validator::make(['validatorkey' => $value], [
|
$validator = Validator::make(['validatorkey' => $value], [
|
||||||
'validatorkey' => $get('rules'),
|
'validatorkey' => $get('rules'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
$message = str($validator->errors()->first())->replace('validatorkey', $get('name'));
|
$message = str($validator->errors()->first())->replace('validatorkey', $get('name'))->toString();
|
||||||
|
|
||||||
$fail($message);
|
$fail($message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]);
|
);
|
||||||
|
|
||||||
$select = Forms\Components\Select::make('variable_value')
|
$select = Forms\Components\Select::make('variable_value')
|
||||||
->hidden($this->shouldHideComponent(...))
|
->hidden($this->shouldHideComponent(...))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user