how can I hide a form field in first repeater

I want one field to be hidden in first item of repeater.
10 Replies
Akshay Bokade
Akshay BokadeOP15mo ago
@pboivin The second option worked, but if we change the value of another field (let's say toggle or select field) the hidden field get shown again.
Patrick Boivin
Patrick Boivin15mo ago
Share your code if you can, I'll see if I have any ideas
Akshay Bokade
Akshay BokadeOP15mo ago
sure @pboivin 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('lastname') ->required() ->label('Lastname') ->maxLength(255) ->live(), Forms\Components\Select::make('country') ->options(Country::all()->pluck('name', 'id')) ->searchable() ->required(), Forms\Components\Select::make('relationship_with_main') ->label('Relationship with main user') ->options(config('app.relationships')) ->required() ->hidden(function() { static $row = 0; return ++$row === 1; }), Forms\Components\Toggle::make('primary') ->label('Primary Applicant') ->inline(false) ->disabled() ->dehydrated() ] ), ]; return $form->schema($this->baseFormSchema($formSpecificComponents)); } -------------------- @pboivin and this component will return to repeater Repeater::make('applicants') ->relationship() ->schema($repeaterComponents) ->itemLabel('test'),
Patrick Boivin
Patrick Boivin15mo ago
Is relationship_with_main part of the repeater?
Akshay Bokade
Akshay BokadeOP15mo ago
Yes @pboivin
Patrick Boivin
Patrick Boivin15mo ago
Sorry, I don't really understand how your form is setup. What is the content of $repeaterComponents?
Akshay Bokade
Akshay BokadeOP15mo ago
$form->schema($this->baseFormSchema($formSpecificComponents));
Patrick Boivin
Patrick Boivin15mo ago
You're passing a form into a repeater schema?
Akshay Bokade
Akshay BokadeOP15mo ago
Yes
Want results from more Discord servers?
Add your server