Add dehydratedWhenHidden to serverVariable TextInput & Select (#1476)

This commit is contained in:
MartinOscar 2025-07-03 08:55:18 +02:00 committed by GitHub
parent de4cb38766
commit 77a3b0640d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 0 deletions

View File

@ -443,6 +443,7 @@ class CreateServer extends CreateRecord
$text = TextInput::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->required(fn (Get $get) => in_array('required', $get('rules')))
->rules(
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
@ -460,6 +461,7 @@ class CreateServer extends CreateRecord
$select = Select::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->options($this->getSelectOptionsFromRules(...))
->selectablePlaceholder(false);

View File

@ -648,6 +648,7 @@ class EditServer extends EditRecord
$text = TextInput::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->required(fn (ServerVariable $serverVariable) => $serverVariable->variable->getRequiredAttribute())
->rules([
fn (ServerVariable $serverVariable): Closure => function (string $attribute, $value, Closure $fail) use ($serverVariable) {
@ -665,6 +666,7 @@ class EditServer extends EditRecord
$select = Select::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->options($this->getSelectOptionsFromRules(...))
->selectablePlaceholder(false);

View File

@ -108,6 +108,7 @@ class Startup extends ServerFormPage
->schema(function () {
$text = TextInput::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->disabled(fn (ServerVariable $serverVariable) => !$serverVariable->variable->user_editable)
->required(fn (ServerVariable $serverVariable) => $serverVariable->variable->getRequiredAttribute())
->rules([
@ -126,6 +127,7 @@ class Startup extends ServerFormPage
$select = Select::make('variable_value')
->hidden($this->shouldHideComponent(...))
->dehydratedWhenHidden()
->disabled(fn (ServerVariable $serverVariable) => !$serverVariable->variable->user_editable)
->options($this->getSelectOptionsFromRules(...))
->selectablePlaceholder(false);