Updated formkit package and modified ApplicantForm to use new FormQuestionBuilder

This commit is contained in:
Asa Yee 2025-12-11 17:01:09 -04:00
parent 835f5f1ab3
commit a35af8989e
2 changed files with 29 additions and 43 deletions

View file

@ -3,7 +3,7 @@
namespace App\Livewire; namespace App\Livewire;
use App\Models\Applicant; use App\Models\Applicant;
use App\Models\FormQuestion; use M21\Formkit\Support\FormQuestionBuilder;
use Filament\Actions\Concerns\InteractsWithActions; use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions; use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Checkbox;
@ -37,20 +37,6 @@ public function mount(): void
$this->form->fill(); $this->form->fill();
} }
public function formQuestion($fieldType, $id){
if ($fieldType === TextInput::class || $fieldType === Textarea::class) {
return $fieldType::make($id)
->label(FormQuestion::find($id)->label)
->placeholder(FormQuestion::find($id)->placeholder)
->required();
}
return $fieldType::make($id)
->label(FormQuestion::find($id)->label)
->required();
}
public function form(Schema $schema): Schema public function form(Schema $schema): Schema
{ {
return $schema return $schema
@ -61,23 +47,23 @@ public function form(Schema $schema): Schema
->description('Your details and contact information') ->description('Your details and contact information')
->schema([ ->schema([
Group::make([ Group::make([
$this->formQuestion(TextInput::class, 'APL_FName'), FormQuestionBuilder::make(TextInput::class, 'APL_FName'),
$this->formQuestion(TextInput::class, 'APL_MName'), FormQuestionBuilder::make(TextInput::class, 'APL_MName'),
$this->formQuestion(TextInput::class, 'APL_LName'), FormQuestionBuilder::make(TextInput::class, 'APL_LName'),
])->columns(3) ])->columns(3)
->columnSpanFull(), ->columnSpanFull(),
$this->formQuestion(Textarea::class, 'APL_Address_1') FormQuestionBuilder::make(Textarea::class, 'APL_Address_1')
->columnSpanFull(), ->columnSpanFull(),
$this->formQuestion(TextInput::class, 'APL_Area'), FormQuestionBuilder::make(TextInput::class, 'APL_Area'),
$this->formQuestion(TextInput::class, 'APL_Gender'), FormQuestionBuilder::make(TextInput::class, 'APL_Gender'),
$this->formQuestion(TextInput::class, 'APL_Email'), FormQuestionBuilder::make(TextInput::class, 'APL_Email'),
$this->formQuestion(TextInput::class, 'APL_PPhone'), FormQuestionBuilder::make(TextInput::class, 'APL_PPhone'),
$this->formQuestion(TextInput::class, 'APL_APhone'), FormQuestionBuilder::make(TextInput::class, 'APL_APhone'),
$this->formQuestion(DatePicker::class, 'APL_DOB'), FormQuestionBuilder::make(DatePicker::class, 'APL_DOB'),
$this->formQuestion(TextInput::class, 'APL_Nationality'), FormQuestionBuilder::make(TextInput::class, 'APL_Nationality'),
$this->formQuestion(TextInput::class, 'APL_BIRTH_PIN'), FormQuestionBuilder::make(TextInput::class, 'APL_BIRTH_PIN'),
$this->formQuestion(TextInput::class, 'APL_ID_TYP'), FormQuestionBuilder::make(TextInput::class, 'APL_ID_TYP'),
$this->formQuestion(TextInput::class, 'APL_ID_Number'), FormQuestionBuilder::make(TextInput::class, 'APL_ID_Number'),
]) ])
->columns(2), ->columns(2),
@ -85,15 +71,15 @@ public function form(Schema $schema): Schema
Step::make('Programme Details') Step::make('Programme Details')
->description('Education, experience and programme selection') ->description('Education, experience and programme selection')
->schema([ ->schema([
$this->formQuestion(TextInput::class, 'APL_HLOE'), FormQuestionBuilder::make(TextInput::class, 'APL_HLOE'),
$this->formQuestion(TextInput::class, 'APL_Employment_Status'), FormQuestionBuilder::make(TextInput::class, 'APL_Employment_Status'),
$this->formQuestion(TextInput::class, 'APL_Programme'), FormQuestionBuilder::make(TextInput::class, 'APL_Programme'),
$this->formQuestion(TextInput::class, 'APL_Attend'), FormQuestionBuilder::make(TextInput::class, 'APL_Attend'),
$this->formQuestion(Textarea::class, 'APL_Experience') FormQuestionBuilder::make(Textarea::class, 'APL_Experience')
->columnSpanFull(), ->columnSpanFull(),
$this->formQuestion(Textarea::class, 'APL_Future_Plans') FormQuestionBuilder::make(Textarea::class, 'APL_Future_Plans')
->columnSpanFull(), ->columnSpanFull(),
$this->formQuestion(Textarea::class, 'APL_How_Found_Programme') FormQuestionBuilder::make(Textarea::class, 'APL_How_Found_Programme')
->columnSpanFull(), ->columnSpanFull(),
]) ])
->columns(2), ->columns(2),
@ -102,13 +88,13 @@ public function form(Schema $schema): Schema
Step::make('Consent & Submission') Step::make('Consent & Submission')
->description('Review and consent') ->description('Review and consent')
->schema([ ->schema([
$this->formQuestion(Checkbox::class, 'APL_Consent_Followup'), FormQuestionBuilder::make(Checkbox::class, 'APL_Consent_Followup'),
$this->formQuestion(Checkbox::class, 'APL_Subscribe_Mailing'), FormQuestionBuilder::make(Checkbox::class, 'APL_Subscribe_Mailing'),
$this->formQuestion(Checkbox::class, 'APL_Photo_Consent'), FormQuestionBuilder::make(Checkbox::class, 'APL_Photo_Consent'),
Fieldset::make('NOTE') Fieldset::make('NOTE')
->schema([ ->schema([
Text::make(new HtmlString('<strong>You must read and accept the following:</strong><br> I hereby declare that the information given in this application is true and correct to the best of my knowledge and belief. If any information given in this application proves to be false or incorrect, I accept the consequences of automatic rejection of the submission and that I may be liable for any breach of the applicable Laws of the Republic of Trinidad and Tobago.')), Text::make(new HtmlString('<strong>You must read and accept the following:</strong><br> I hereby declare that the information given in this application is true and correct to the best of my knowledge and belief. If any information given in this application proves to be false or incorrect, I accept the consequences of automatic rejection of the submission and that I may be liable for any breach of the applicable Laws of the Republic of Trinidad and Tobago.')),
$this->formQuestion(Checkbox::class, 'APL_Accepts'), FormQuestionBuilder::make(Checkbox::class, 'APL_Accepts'),
])->columnSpanFull() ])->columnSpanFull()
->columns(1), ->columns(1),
]), ]),

6
composer.lock generated
View file

@ -3303,11 +3303,11 @@
}, },
{ {
"name": "m21/formkit", "name": "m21/formkit",
"version": "v1.0.4", "version": "v1.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://codebay.msya.gov.tt/DevTeam/formkit.git", "url": "https://codebay.msya.gov.tt/DevTeam/formkit.git",
"reference": "dc6926f5379a1befbfc268a56d3190e738318c5a" "reference": "46b96ce6fc363b0e577d7f4d37fc09244898b3a9"
}, },
"require": { "require": {
"filament/filament": "^4.0", "filament/filament": "^4.0",
@ -3337,7 +3337,7 @@
} }
], ],
"description": "Form components for M21 application programmes and related services", "description": "Form components for M21 application programmes and related services",
"time": "2025-12-11T17:19:39+00:00" "time": "2025-12-11T20:55:43+00:00"
}, },
{ {
"name": "masterminds/html5", "name": "masterminds/html5",