Added description loaded logic in editing in process order screen
This commit is contained in:
@@ -23,7 +23,8 @@ use Filament\Tables\Actions\ExportAction;
|
|||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use App\Filament\Exports\ProcessOrderExporter;
|
use App\Filament\Exports\ProcessOrderExporter;
|
||||||
use App\Filament\Imports\ProcessOrderImporter;
|
use App\Filament\Imports\ProcessOrderImporter;
|
||||||
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Forms\Set;
|
||||||
|
|
||||||
class ProcessOrderResource extends Resource
|
class ProcessOrderResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -83,10 +84,26 @@ class ProcessOrderResource extends Resource
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('item_description')
|
Forms\Components\TextInput::make('item_description')
|
||||||
->label('Description')
|
->label('Description')
|
||||||
->required()
|
->required()
|
||||||
->reactive(),
|
->reactive()
|
||||||
|
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||||
|
$itemId = $get('item_id');
|
||||||
|
if ($get('id')) {
|
||||||
|
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
||||||
|
if ($item) {
|
||||||
|
$set('item_description', $item);
|
||||||
|
} else {
|
||||||
|
$set('item_description', null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
// ->readOnly(true),
|
// ->readOnly(true),
|
||||||
Forms\Components\TextInput::make('process_order')
|
Forms\Components\TextInput::make('process_order')
|
||||||
->label('Process Order')
|
->label('Process Order')
|
||||||
@@ -277,7 +294,6 @@ class ProcessOrderResource extends Resource
|
|||||||
// ->send();
|
// ->send();
|
||||||
// }),
|
// }),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
->default(Filament::auth()->user()?->name),
|
->default(Filament::auth()->user()?->name),
|
||||||
|
|||||||
Reference in New Issue
Block a user