Sleepless
Sleepless
FFilament
Created by Sleepless on 4/15/2024 in #❓┊help
Repeater By VirtualColumn
Hello , I have a question about using the Repeater Form Element. My Model has a json-array-column named 'data' where data of the repeater is stored. i need to extract this data column into another database Table. how can I access this data, since it's not a HasMany Relation? ```php // Current Implementation $schema[] = Repeater::make('data') ->label(__('miniapp.fields')) // Connection to new Model where the needed would again be in the data column public function modelversiondata(): hasOne { return $this->HasMany(ModelVersion::class, 'model_id', 'id') ->select('data') ->where('version_id', '=', session('version')) ->first(); }
2 replies
FFilament
Created by Sleepless on 3/13/2024 in #❓┊help
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'),
2 replies