mathan7136
How to hide one field in repeater form ( only in first element )??
when i using this code. ->hidden(function($component) {
$uuid = collect(explode('.', $component->getStatePath()))
->slice(0, -2)
->pop();
return collect($this->getFormStatePath())->keys()->search($uuid) !== 0;
}), primary hidden permanently !!!, i need to hide only in first element my results, dd(uuid) = applicants
36 replies
How to hide one field in repeater form ( only in first element )??
i tried this also but when i click primary in seconf form, the first one's primary automatically visibled
->hidden(function() {
static $position = 0;
$position++;
if($position == 1) {
return true;
}
}),
36 replies
How to hide one field in repeater form ( only in first element )??
In this condition i need to add '<', after i add this
->hidden(fn(\Filament\Forms\Get $get) => count($get('../../applicants')) == 1),its working but when i click add another its showing in both parent and child forms
36 replies
How to hide one field in repeater form ( only in first element )??
App\Filament\Frontend\Resources\ApplicationResource\Pages\Edit\Applicants::App\Filament\Frontend\Resources\ApplicationResource\Pages\Edit{closure}(): Argument #1 ($get) must be of type Closure, Filament\Forms\Get given, called in /Users/ranium/Desktop/sites/projects/caseflow-main/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
36 replies
How to hide one field in repeater form ( only in first element )??
protected function baseFormSchema(array $repeaterComponents): array
{
return [
$this->descriptionPlaceholder(),
Repeater::make('applicants')
->relationship()
->schema($repeaterComponents)
->mutateRelationshipDataBeforeSaveUsing(function (array $data, Model $record): array {
// Check if 'meta' exists in both $data and $record
if (isset($data['meta']) && isset($record->meta)) {
// Merge the 'meta' data from the record with the new data
$data['meta'] = array_merge_recursive($record->meta, $data['meta']);
}
return $data;
})
->itemLabel(fn (array $state) => "{$state['firstname']} {$state['lastname']}"),
];
}
36 replies
How to hide one field in repeater form ( only in first element )??
public function form(Form $form): Form
{
$formSpecificComponents = [
Forms\Components\Grid::make(3)
->schema(
[
Forms\Components\TextInput::make('firstname')
->required()
->label('Firstname')
->required()
->maxLength(255)
->live(),
Forms\Components\TextInput::make('middlename')
->label('Middlename')
->maxLength(255),
Forms\Components\TextInput::make('lastname')
->required()
->label('Lastname')
->maxLength(255)
->live(),
Forms\Components\DatePicker::make('date_of_birth')
->required(),
Forms\Components\Select::make('meta.country_of_birth')
->options(Country::all()->pluck('name', 'id'))
->searchable()
->required(),
Forms\Components\TextInput::make('meta.town_of_birth')
->maxLength(255)
->required(),
Forms\Components\Toggle::make('primary')
->label('Primary Applicant'),
]
),
];
return $form->schema($this->baseFormSchema($formSpecificComponents));
}
36 replies