Added id column to load default plant with its validation functionality
This commit is contained in:
@@ -36,11 +36,12 @@ class MotorTestingMasterResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Item::latest()->first())->plant_id;
|
return optional(MotorTestingMaster::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -226,6 +227,9 @@ class MotorTestingMasterResource extends Resource
|
|||||||
Forms\Components\Hidden::make('updated_by')
|
Forms\Components\Hidden::make('updated_by')
|
||||||
->default(fn () => Filament::auth()->user()?->name)
|
->default(fn () => Filament::auth()->user()?->name)
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user