peterkeri
peterkeri
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
nope, thanks for your time!
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
i try to move the update part of my action to the after() function, but the same happened..
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
And i dont understand why updated because i use this:
$record->is_active = 0;
$record->save();
$record->is_active = 0;
$record->save();
As i know this need to update only is_active field
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
correct
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
I made a screencast of the whole process
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
@.valpuia
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
Ok, just a sec
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
i have to store all posted data into a new record, so i dont have to disable form element in the custom edit form (what i created for this action)
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
@.valpuia Before added ->dehydrated(false), if I called
$record->is_active = 0;
$record->save();
$record->is_active = 0;
$record->save();
the save() updated the meta property too (meta stored in another table with hasOne relation) in the database with the posted meta data (what is dirty or not) for the original record. I don't want it, I want update ONLY the is_active field. Now the meta data not udpated - as you said - beacuse of dehydration.
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
@.valpuia now the related data not updated --> it seems okay. i think only one thing left: the related data (meta stored in another table with hasOne relation) not created when i call static::getModel()::create($data) function for the new record
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
@.valpuia ok, i made the changes, now: - the edit form filled with data --> OK - the edited record set to inactive --> OK - the new record created -- OK problems: my main problem has NOT solved. As you see the key-value component use a relationship. This data has been updated too when I use this:
$record->is_active = 0;
$record->save();
$record->is_active = 0;
$record->save();
Here is the action:
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('versioned_edit')
->mountUsing(fn (Model $record, Forms\ComponentContainer $form) => $form->fill([
'name' => $record->name
]))
->action(function (Model $record, array $data): void {
$record->is_active = 0;
$record->save();

static::getModel()::create($data);
})
->form([
Forms\Components\Section::make('Default data')
->columns([
'sm' => 1,
'md' => 2,
'xl' => 2
])
->schema([
Forms\Components\TextInput::make('name')
->required()
->string()
->maxLength(255),
Forms\Components\TextInput::make('description')
->nullable()
->string()
->maxLength(255),
]),
Forms\Components\Section::make('Meta data')
->relationship('meta')
->schema([
Forms\Components\KeyValue::make('data')
->required()
->label('Meta data')
])
])
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('versioned_edit')
->mountUsing(fn (Model $record, Forms\ComponentContainer $form) => $form->fill([
'name' => $record->name
]))
->action(function (Model $record, array $data): void {
$record->is_active = 0;
$record->save();

static::getModel()::create($data);
})
->form([
Forms\Components\Section::make('Default data')
->columns([
'sm' => 1,
'md' => 2,
'xl' => 2
])
->schema([
Forms\Components\TextInput::make('name')
->required()
->string()
->maxLength(255),
Forms\Components\TextInput::make('description')
->nullable()
->string()
->maxLength(255),
]),
Forms\Components\Section::make('Meta data')
->relationship('meta')
->schema([
Forms\Components\KeyValue::make('data')
->required()
->label('Meta data')
])
])
])
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
@.valpuia i have this:
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('versioned_edit')
->mountUsing(fn (Forms\ComponentContainer $form) => $form->fill())
->action(function (Model $record, array $data): void {
//$this->record->author()->associate($data['authorId']);
//$this->record->save();
})
->form([
Forms\Components\Section::make('Default data')
->columns([
'sm' => 1,
'md' => 2,
'xl' => 2
])
->schema([
Forms\Components\TextInput::make('name')
->required()
->string()
->maxLength(255),
Forms\Components\TextInput::make('description')
->nullable()
->string()
->maxLength(255),
]),
Forms\Components\Section::make('Meta data')
->relationship('meta')
->schema([
Forms\Components\KeyValue::make('data')
->required()
->label('Meta data')
])
])
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('versioned_edit')
->mountUsing(fn (Forms\ComponentContainer $form) => $form->fill())
->action(function (Model $record, array $data): void {
//$this->record->author()->associate($data['authorId']);
//$this->record->save();
})
->form([
Forms\Components\Section::make('Default data')
->columns([
'sm' => 1,
'md' => 2,
'xl' => 2
])
->schema([
Forms\Components\TextInput::make('name')
->required()
->string()
->maxLength(255),
Forms\Components\TextInput::make('description')
->nullable()
->string()
->maxLength(255),
]),
Forms\Components\Section::make('Meta data')
->relationship('meta')
->schema([
Forms\Components\KeyValue::make('data')
->required()
->label('Meta data')
])
])
])
Questions: - that is what you think? if yes: - how can i filled the form with data (now the form is empty)? - I got an error to $this->record: undefined property
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
ok, I try it, thanks!
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
Long story short: i have to revision all property changes
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
The package type records with active flag are used for select options. (So if you create a shipment order choose from the active verison of package type records)
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
I have shipment orders what has different properties (for example package types). This package types contains important values (what we used for accountant modules). When a shipment record created it used the currently active package type entry. I should NOT modify these data, so thats why I have to create a new version of the package type recod every time when any data has changed. So all shipment orders used "his version" of the package tpye. i hope i can explain it clearly
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
wait, i'll explain.. just a sec
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
the record what is active used by for select fields (these are the actual entries)
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
not exactly, but almost.. the record (what I have to inactive) will be used by orders what created at the past
39 replies
FFilament
Created by peterkeri on 7/26/2023 in #❓┊help
Update only one field in a custom action?
so i have to create a custom action what is replicating the original record and then inactive it?
39 replies