mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-29 16:44:44 +02:00
Set the node
This commit is contained in:
parent
a1067fd4aa
commit
0cb7f737b0
@ -23,6 +23,8 @@ class CreateServer extends CreateRecord
|
|||||||
protected static string $resource = ServerResource::class;
|
protected static string $resource = ServerResource::class;
|
||||||
protected static bool $canCreateAnother = false;
|
protected static bool $canCreateAnother = false;
|
||||||
|
|
||||||
|
public ?Node $node = null;
|
||||||
|
|
||||||
public function form(Form $form): Form
|
public function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
@ -77,13 +79,16 @@ class CreateServer extends CreateRecord
|
|||||||
Forms\Components\Select::make('node_id')
|
Forms\Components\Select::make('node_id')
|
||||||
->disabledOn('edit')
|
->disabledOn('edit')
|
||||||
->prefixIcon('tabler-server-2')
|
->prefixIcon('tabler-server-2')
|
||||||
->default(fn () => Node::query()->latest()->first()?->id)
|
->default(fn () => ($this->node = Node::query()->latest()->first())?->id)
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->live()
|
->live()
|
||||||
->relationship('node', 'name')
|
->relationship('node', 'name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->preload()
|
->preload()
|
||||||
->afterStateUpdated(fn (Forms\Set $set) => $set('allocation_id', null))
|
->afterStateUpdated(function (Forms\Set $set, $state) {
|
||||||
|
$set('allocation_id', null);
|
||||||
|
$this->node = Node::find($state);
|
||||||
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\Select::make('allocation_id')
|
Forms\Components\Select::make('allocation_id')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user