miomech
miomech
FFilament
Created by miomech on 3/15/2024 in #❓┊help
How to mutate/format data for dehydration? (When using a custom field class)
Hi there, I know how to do this using the premade filament fields. I created a custom field component. And it works great. But I need to mutate the data that comes from the database so it display properly on my custom text field. Laravel returns back a custom cast object when accessing it from the database (not a singular raw string). So I need to be able to mutate that data to grab a single key from the array. otherwise nothing displays on the UI. TLDR: how do i use the functionality of (formatStateUsing or dehydrateStateUsing) within a custom component class? https://filamentphp.com/docs/3.x/forms/fields/custom#custom-field-classes
TextInput::make('A field')
->formatStateUsing(function (MoneyInput $component, $state) {
...
})
->dehydrateStateUsing(function (MoneyInput $component, $state) {
...
});
TextInput::make('A field')
->formatStateUsing(function (MoneyInput $component, $state) {
...
})
->dehydrateStateUsing(function (MoneyInput $component, $state) {
...
});
I've tried mutating the data within the setup() function but that doesn't work... Thanks for your help!
3 replies
FFilament
Created by miomech on 7/21/2023 in #❓┊help
Filament v2 Is it possible to render a relation manager outside of the admin dashboard on blade
Hello I was hoping someone could guide me in the right direction, I'm pretty familiar with the v2 docs but cant seem to find anything about how to render a relation manager in a regular blade template. There are plenty of docs for how to use tables and forms in blade but nothing about how to use relationmanagers alongside them tried using phind.com (AI) to see if it would throw out some random ideas and it suggested this
PHP
$postsRelationManager = new PostsRelationManager($parentModel, $relationship);
$postsRelationManager->render();
PHP
$postsRelationManager = new PostsRelationManager($parentModel, $relationship);
$postsRelationManager->render();
but of course that does not seem to work
8 replies