ziolupo
ziolupo
Explore posts from servers
FFilament
Created by ziolupo on 5/3/2024 in #❓┊help
Filter on table went to fullpage in 3.2.70 filament release.
It worked! I didn't think about it! Thank you so much!
6 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
I just find a different solution: instead of passing the component_id and modifying the blade file for accepting it, you can do something like this in foundContact()
#[On('foundContact')]
public function foundContact($contact_id)
{
$this->dispatch('close-modal', id: $this->getId().'-form-component-action');
$this->contact_id=$contact_id;
$contact=Contact::find($contact_id);
$this->data['contact_id'] = $contact_id;
$this->data['country'] = $contact->country;
$this->data['company'] = $contact->societa;
}
#[On('foundContact')]
public function foundContact($contact_id)
{
$this->dispatch('close-modal', id: $this->getId().'-form-component-action');
$this->contact_id=$contact_id;
$contact=Contact::find($contact_id);
$this->data['contact_id'] = $contact_id;
$this->data['country'] = $contact->country;
$this->data['company'] = $contact->societa;
}
Didn't know which is the best approach
15 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
So easy! I owe you a beer! Or maybe two!
15 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
I got it! Now I can close the modal. I have to thank you for your support. There is just one problem yet, sorry if I abuse of your patience. The problem is something I didn't think about in the beginning when I started with this approch and it is the following. My action is done in this way:
Action::make('findContact')
->icon('heroicon-o-question-mark-circle')
->action(function (Component $livewire, Set $set, array $data, ?Contact $record): void {
Log::info("Setting the form");
if($livewire->contact_id){
$contatto=Contact::find($livewire->contact_id);
$set('contact_id',$contatto->id);
$set('country',$contatto->country);
}
})
->color('primary')
->iconButton()
->modalHeading('Find Contact')
->modalContent(function (Component $livewire, Forms\Get $get) {
return view('filament.modal.contacttable', [
'componentId' => $livewire->getId(),
]);
})
->slideOver()
)
Action::make('findContact')
->icon('heroicon-o-question-mark-circle')
->action(function (Component $livewire, Set $set, array $data, ?Contact $record): void {
Log::info("Setting the form");
if($livewire->contact_id){
$contatto=Contact::find($livewire->contact_id);
$set('contact_id',$contatto->id);
$set('country',$contatto->country);
}
})
->color('primary')
->iconButton()
->modalHeading('Find Contact')
->modalContent(function (Component $livewire, Forms\Get $get) {
return view('filament.modal.contacttable', [
'componentId' => $livewire->getId(),
]);
})
->slideOver()
)
As you can see in ->action I'm setting the value of some fields using what I have received through the dispatch. This is working perfectly if I hit "SAVE" (or somthing similar) in the modal. But if I'm closing the modal programmatically the function in -> action() is never called. So most probably I have to set the values from here:
#[On('foundContact')]
public function foundContact($contact_id)
{
// $this->contatto=Contact::find($contact_id);
$this->contact_id=$contact_id;

--->>> HERE I HAVE TO SET THE COMPONENT <<<---
}
#[On('foundContact')]
public function foundContact($contact_id)
{
// $this->contatto=Contact::find($contact_id);
$this->contact_id=$contact_id;

--->>> HERE I HAVE TO SET THE COMPONENT <<<---
}
But I didn't find a way. Later I will check into the filament source code to see if there is an hint for doing that. . Thank you again
15 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
Dear Wbzy, the dispatch for data is working like a charm. What I'm not able to do is closing the modal. My modal was open in this way:
->suffixAction(
Action::make('findContact')
->icon('heroicon-o-question-mark-circle')
->action(function (Forms\Get $get, Forms\Set $set, Component $livewire){
dd($livewire);
})
->color('primary')
->iconButton()
->modalHeading('Find Contact')
->modalContent(view('filament.modal.contacttable'))
->slideOver()
)
->suffixAction(
Action::make('findContact')
->icon('heroicon-o-question-mark-circle')
->action(function (Forms\Get $get, Forms\Set $set, Component $livewire){
dd($livewire);
})
->color('primary')
->iconButton()
->modalHeading('Find Contact')
->modalContent(view('filament.modal.contacttable'))
->slideOver()
)
I don't have any idea how can I close it. I don't know the id or name... or what is needed here:

$livewire->dispatch('close-modal', id: $this->componentId.'-form-component-action');

$livewire->dispatch('close-modal', id: $this->componentId.'-form-component-action');
15 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
mmhh... very interesting... You put the listener in the create page... interesting.. pages are livewire object... resources are not! Maybe is this my problem! During the weekend I will try to adapt your solution to my needs and I will let you know. Thank you for showing the way! (This is the way...cit.)
15 replies
FFilament
Created by Wbzy on 12/8/2023 in #❓┊help
How to listen to dispatch events in form?
Did you solve the issue? I 'm interested in the solution
15 replies
FFilament
Created by ziolupo on 12/18/2023 in #❓┊help
Open modal with table for searching the right element
We are speakig about more than 10000 contacts identified and categorized with a lot of fields. I tried to think how to do that with a select. But there are at least 10 different common fields where I could search and most of the time with logical AND between the various fields. Select if perfect if your research plays in the minor league. For the major league you need something more complex. 😆 Of course there is a work around: find the contact in the contact-resource (with all the search fields that you need) and add an action for the creating -let me say- an "Offer". The problem is than you need a button for every kind of activity you want to do on that contact. Not impossible but not nice IMHO.
14 replies
FFilament
Created by ziolupo on 12/18/2023 in #❓┊help
Open modal with table for searching the right element
Thanks, I will take a look @ Sebastiaan work. I'm quite surprised about "this is not a common task", Lara. In a lot of software is really a common task. Just an example: you have to insert an emailm but you remember only that is form Spain, and the real name is Pablo, and family name is starting with... damn... oh yes, is starting with "DE". Easy to find if you have a modal with a table and some filters... near impossible to find in a SELECT BOX...
14 replies
FFilament
Created by ziolupo on 12/18/2023 in #❓┊help
Open modal with table for searching the right element
Thank Lara Zeus. THis is more or less what I need. Unlucky the plugin is not ready yet (as far as I know)
14 replies
FFilament
Created by ziolupo on 12/18/2023 in #❓┊help
Open modal with table for searching the right element
Really not even an hint?
14 replies
FFilament
Created by Ostap Brehin 🇺🇦 on 12/24/2023 in #❓┊help
Table action that opens a modal with a table inside? (how to use `->table` on an action?)
I'm very interestin in this topic. It should be nice to understand event how to have back the row after clicking on it
4 replies
FFilament
Created by Robin on 12/25/2023 in #❓┊help
Repeater
Maybe this can help. I have a repeater, when I toggle to true one item, all the toggle button of the other must be set to false. This is my code used inside the repeater:
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set, Get $get)
{
$items=$get('../../exhibitionWines'); // The name of the repeater
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false); //The "other" items
}
}
}
})
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set, Get $get)
{
$items=$get('../../exhibitionWines'); // The name of the repeater
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false); //The "other" items
}
}
}
})
12 replies
FFilament
Created by ziolupo on 11/3/2023 in #❓┊help
Repeater with only one record with Toggle active
At the end I was able to find a solution. Here below the code:
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set,Get $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false);
}
}
}
})
->label('MC')
->inline(false),
])->columns(4),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SAVE
</x-filament::button>
')
))
->extraAttributes(['class' => 'flex justify-center']),
])->compact()
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->makeTitle())
->schema([
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,Set $set,Get $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('wine_id');
if($state==true){
foreach ($items as $key => $item) {
if ($item['wine_id']!=$current_id){
$set("../../exhibitionWines.{$key}.in_masterclass",false);
}
}
}
})
->label('MC')
->inline(false),
])->columns(4),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SAVE
</x-filament::button>
')
))
->extraAttributes(['class' => 'flex justify-center']),
])->compact()
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
}
6 replies
FFilament
Created by ziolupo on 11/3/2023 in #❓┊help
Repeater with only one record with Toggle active
Thank you Awcodes. I was able to read the array you were mentioning, but not able to set value. This is the last version of my code:
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,callable $set, callable $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('id');
foreach ($items as $key => $item) {
if ($item['id']!=$current_id){
$set($item['in_masterclass'],false);
}
}
})
->label('MC')
->inline(false),
])->columns(4),
Repeater::make('exhibitionWines')
->hiddenLabel()
->relationship()
->schema([
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
->native(false)
->required()
->preload()
->columnSpan(3),
Forms\Components\Toggle::make('in_masterclass')
->reactive()
->live()
->afterStateUpdated(function($state,callable $set, callable $get)
{
$items=$get('../../exhibitionWines');
$current_id=$get('id');
foreach ($items as $key => $item) {
if ($item['id']!=$current_id){
$set($item['in_masterclass'],false);
}
}
})
->label('MC')
->inline(false),
])->columns(4),
6 replies
FFilament
Created by ziolupo on 11/2/2023 in #❓┊help
Submit button inside section in livewire component
Thank you Vp! It's working like a charm. Here below the complete code if needed by other people! Thanks again, didn't now about Blade:render ! .
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->entity->name)
->schema([
Repeater::make('exhibitionWines')
->label("Vini per evento")
->relationship()
->simple(
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
// ->options(Wine::where('winery_id', '=', auth()->user()->winery->id)->get()->pluck('name', 'id'))
->native(false)
->preload(),
)->addActionLabel('Aggiungi Vino all\'evento'),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SALVA I VINI
</x-filament::button>
'))
)
->extraAttributes(['class' => 'flex justify-center']),
])->compact(),
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Group::make()
->schema([
Forms\Components\Section::make($this->entity->name)
->schema([
Repeater::make('exhibitionWines')
->label("Vini per evento")
->relationship()
->simple(
Forms\Components\Select::make('wine_id')
->relationship('wine', 'name')
// ->options(Wine::where('winery_id', '=', auth()->user()->winery->id)->get()->pluck('name', 'id'))
->native(false)
->preload(),
)->addActionLabel('Aggiungi Vino all\'evento'),
Forms\Components\Placeholder::make('savePersonal')
->label('')
->content(new HtmlString(
Blade::render('
<x-filament::button type="submit">
SALVA I VINI
</x-filament::button>
'))
)
->extraAttributes(['class' => 'flex justify-center']),
])->compact(),
])->columnSpan(2),
])
->columns(4)
->model($this->entity)
->statePath('entityData');
}
6 replies
FFilament
Created by ziolupo on 10/23/2023 in #❓┊help
fileupload hang when I drop new image
Believe me or not... I guessed the same. 😆
6 replies
FFilament
Created by ziolupo on 10/23/2023 in #❓┊help
fileupload hang when I drop new image
I tried using the SpatieMediaLibrary and there is the same bug. Do you know about any workaround?
6 replies
FFilament
Created by ziolupo on 10/7/2023 in #❓┊help
Error in extending tables
Thanks DrByte. I investigate further "under the hood" and it's exactly as you are saying. About the result, I already achieved that with CSS or by changing the original code (I know that is something not to do... 🙂 ... but as I was saying from the beginning, I was more interested in the possibility, without a particular ussue or problem to be solved. Thanks again
15 replies
FFilament
Created by ziolupo on 10/7/2023 in #❓┊help
Error in extending tables
Honestly speaking I don't have anything that I want to do with the new class...b ut I can easily find. For example a class "compact", or a class where I can dynamically change the padding. But the idea was just having a new class for playing.
15 replies