Repeater set a Variable per Field

Hello There I'm creating a Form with a Repeater Element. For each Field in that Repeater I need to calculate if it's readonly or not. For this I use the Function 'Model::checkIfModelFieldHasData($models_id, $get('name'))' Based on the result of this call, i need to make all Inputs in the Repeater Field readonly. How can I achieve this without calling this function separately for each Input in my Repeater. Code:
$schema[] = Repeater::make('data')
->label(__('miniapp.fields'))
->schema([
TextInput::make('name')
->label(__('miniapp.name'))
->required()
->readonly(fn ($get) => Model::checkIfModelFieldHasData($models_id, $get('name')))
->hint(fn ($get) => (Model::checkIfModelFieldHasData($models_id, $get('name')) ? __('miniapp.fieldnoteditable') : '' ) )
->hintColor('warning'),
$schema[] = Repeater::make('data')
->label(__('miniapp.fields'))
->schema([
TextInput::make('name')
->label(__('miniapp.name'))
->required()
->readonly(fn ($get) => Model::checkIfModelFieldHasData($models_id, $get('name')))
->hint(fn ($get) => (Model::checkIfModelFieldHasData($models_id, $get('name')) ? __('miniapp.fieldnoteditable') : '' ) )
->hintColor('warning'),
0 Replies
No replies yetBe the first to reply to this messageJoin