© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Citizer

How to add data to a model without creating a field

Hello!
When creating a record, I want to add some data to a nested relationship (using a repeater).
If I add a field to the form and enter data into it manually, everything works fine. But I would like to add this data programmatically, using for example afterStateUpdated. Without creating a field. Do I have this opportunity? Thanks for the possible answers!

Code:
Forms\Components\Repeater::make('attributes')
->label('Additional attributes')
->relationship('attributes')
->schema(function ($get, $set, $component) {
return self::renderAttributesFields($get, $set, $component);
}
)
->reactive()
->addable(false)
->deletable(false)
->hidden(function (Get $get): bool {
if ($get('rule_type_id') !== null) {
return empty(RuleType::find($get('rule_type_id'))->ruleAttributes->pluck('name')->toArray());
}
return true;
})


public static function renderAttributesFields(Get $get, Set $set): array {
$arrayFields = [];
if ($get('rule_type_id') !== null) {
$ruleAttributes = RuleType::find($get('rule_type_id'))->ruleAttributes;
foreach ($ruleAttributes as $item) {

$arrayFields[] = Forms\Components\TextInput::make('rule_attribute_id');
//That's how it works. But I don't want to create a field, I would like to just
//$set('rule_attribute_id', $item->id);

**
return $arrayFields;
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to add data to a model without creating a field
FilamentFFilament / ❓┊help
2y ago
how to resources field data in model
FilamentFFilament / ❓┊help
3y ago
Save a field when creating a model
FilamentFFilament / ❓┊help
2y ago
get a Field data in model
FilamentFFilament / ❓┊help
3y ago