victorcamposramirez
victorcamposramirez
FFilament
Created by victorcamposramirez on 5/1/2025 in #❓┊help
Workaround for deleteOptionAction
In Filament, we have a createOptionAction to add new values to a Select which is related to another model. Also, we have an editOptionAction. But we have not a deleteOptionAction. So I tried to add a delete button inside the editOptionAction using . The button renders fina, but it simply doesn't do anything. Here is my code so far:
Select::make('uom_category_id')
->relationship('category', 'name')
->createOptionForm([
TextInput::make('name')
->label('Nombre')
->required()
->placeholder('Nombre de la categoría de unidad de medida'),
])
->createOptionAction(fn ($action) => $action->modalWidth('xs'))
->editOptionForm([
TextInput::make('name')
->label('Nombre')
->required()
->placeholder('Nombre de la categoría de unidad de medida'),
])
->editOptionAction(fn ($action) => $action->modalWidth('xs')
// Botón para eliminar la categoría de unidad de medida
->extraModalFooterActions(function ($action, $record) {
return [
Action::make('delete')
->label('Eliminar')
->action(function () use ($record) {
$record->category->delete();
$this->notify('success', 'Categoría de unidad de medida eliminada');
})
->color('danger')
->requiresConfirmation()
];
})
)
->required()
->label('Categoría de unidad de medida'),
Select::make('uom_category_id')
->relationship('category', 'name')
->createOptionForm([
TextInput::make('name')
->label('Nombre')
->required()
->placeholder('Nombre de la categoría de unidad de medida'),
])
->createOptionAction(fn ($action) => $action->modalWidth('xs'))
->editOptionForm([
TextInput::make('name')
->label('Nombre')
->required()
->placeholder('Nombre de la categoría de unidad de medida'),
])
->editOptionAction(fn ($action) => $action->modalWidth('xs')
// Botón para eliminar la categoría de unidad de medida
->extraModalFooterActions(function ($action, $record) {
return [
Action::make('delete')
->label('Eliminar')
->action(function () use ($record) {
$record->category->delete();
$this->notify('success', 'Categoría de unidad de medida eliminada');
})
->color('danger')
->requiresConfirmation()
];
})
)
->required()
->label('Categoría de unidad de medida'),
Here I'm working with tow models called Uom (Unit Of Measure) and UomCategory. I don't want to create a full Resource only for CRUD of UomCategory if it's not necessary. Can you give me any advise or tip? Thanks in advance!
4 replies
FFilament
Created by victorcamposramirez on 4/25/2025 in #❓┊help
Upload image from table
Hi there! Has anyone ever tried uploading images from a table using ImageColumn? I mean being able to upload an avatar, for example, by clicking on an ImageColumn or something similar. From the documentation, I understand it's not possible, but is there any plugin or approach to achieve this?
4 replies
FFilament
Created by victorcamposramirez on 3/11/2025 in #❓┊help
Customize Select in Relation Manager
Hi there! I have a model with a Relation Manager, relating Product and Allergen models. What I'm trying to do is show image and description of allergen in the Select component inside the AttachAction modal of the RelationManager. Something similar to this: https://v2.filamentphp.com/tricks/render-html-in-select-options So, here is my code:
->headerActions([
Tables\Actions\AttachAction::make()
->recordSelect(function (Select $select) {
$select->getOptionLabelUsing(function ($record) {
dd($record);
return new HtmlString(<<<HTML
<div class="flex items center">
<div class="flex-shrink-0 h-8 w-8 mr-2">
<img class="h-8 w-8 rounded-full" src="{$record->icon}" alt="">
</div>
<div class="text-sm">
<div class="font-medium">{$record->name}</div>
<div class="text-xs text-gray-500">{$record->description}</div>
</div>
</div>
HTML);
})
->placeholder("Selecciona los alérgenos de la lista")
->searchable(false)
->allowHtml()
->multiple(true);
return $select;
})
->preloadRecordSelect()
])
->headerActions([
Tables\Actions\AttachAction::make()
->recordSelect(function (Select $select) {
$select->getOptionLabelUsing(function ($record) {
dd($record);
return new HtmlString(<<<HTML
<div class="flex items center">
<div class="flex-shrink-0 h-8 w-8 mr-2">
<img class="h-8 w-8 rounded-full" src="{$record->icon}" alt="">
</div>
<div class="text-sm">
<div class="font-medium">{$record->name}</div>
<div class="text-xs text-gray-500">{$record->description}</div>
</div>
</div>
HTML);
})
->placeholder("Selecciona los alérgenos de la lista")
->searchable(false)
->allowHtml()
->multiple(true);
return $select;
})
->preloadRecordSelect()
])
I've skipped linking it to a view until I could check it were working. Unfortunately, even when the placeholder(), searchable() and multiple() methods are working fine, it seems to be ignoring the getOptionLabelUsing() method. I've tried also getOptionLabelsUsing() (I can't tell the difference between both methos yet because I'm still a Filament newbie). Is there something I'm doing wrong here? It is not the right way, maybe?
5 replies
FFilament
Created by victorcamposramirez on 3/5/2025 in #❓┊help
FileUpload (avatar) when record is in other model
No description
24 replies
FFilament
Created by victorcamposramirez on 3/5/2025 in #❓┊help
Change the size of RelationManager's create/edit modal?
I have a RelationManager created to manage Product assets. I've done my form with ID (hidden), name, type, file and is_primary (bool). I've arranged the form to 1 column, but I'd like to change modal width so the fields don't show so long. When talking about Actions, you can change the width of the modal by using the modalWidth() method. Is this posible in a RelationManager's create/edit modal?
4 replies
FFilament
Created by victorcamposramirez on 3/4/2025 in #❓┊help
Change navigation icon size
Is there a way to change navigation item icon size? I'm using the FontAwesome's icon set and the default Tailwind w-6 classes for the sidebar's item icons are quite large for me. Instead I'd like to use w-5 so the icons are represented in a more compact look.
4 replies