Skip to content

Instantly share code, notes, and snippets.

@billydekid
Created April 18, 2024 00:59
Show Gist options
  • Select an option

  • Save billydekid/51cacb94ef3fec7eed3281dfe7330107 to your computer and use it in GitHub Desktop.

Select an option

Save billydekid/51cacb94ef3fec7eed3281dfe7330107 to your computer and use it in GitHub Desktop.
Hidden field tidak ke-save
// hasil dd($this->data)
array:6 [▼ // app/Filament/Resources/ProjectResource/Pages/CreateProject.php:30
"project_name" => "Ikan Mas 3"
"project_code" => "IKANMAS3"
"workflow_type_id" => "2"
"due_date" => "2024-04-26"
"note" => "dtest"
"docid" => array:1 [▼
"4487a3f6-dff9-4fdf-8977-de4e7479bcfa" => "01HVQBBWMDJ4G9TR1GAPVCTCQR.txt"
]
]
<?php
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('project_name')
->required()
->maxLength(64),
Forms\Components\TextInput::make('project_code')
->required()
->disabledOn('edit')
->maxLength(64),
Forms\Components\Select::make('workflow_type_id')
->relationship(name: 'workflowType', titleAttribute: 'workflow_name')
->disabledOn('edit')
->live()
->required(),
Forms\Components\Section::make('Document(s) required')
->visible(fn (Get $get): bool => is_numeric($get('workflow_type_id')))
->description('Type of docs required for this project')
->schema(
// ...
// self::Files(),
function (Get $get): Array
{
$schema = [];
if($get('workflow_type_id'))
{
$wftid = DB::table('document_type_workflow_type')->where('workflow_type_id', $get('workflow_type_id'))->get();
foreach($wftid as $value)
{
// dd(Forms\Components\Hidden::make('document_type_id'));
array_push($schema,
Forms\Components\FileUpload::make('docid')->label('Dokumen ' . DocumentType::find($value->document_type_id)->doc_name),
// mengapa Hidden field tidak tampil di $this->data pada page CreateProject.php
Forms\Components\Hidden::make('document_type_id')->default($value->document_type_id)
);
}
}
return $schema;
}
),
Forms\Components\DatePicker::make('due_date')
->required(),
Forms\Components\Textarea::make('note')
->columnSpanFull(),
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment