F
Filament5mo ago
o.m

Calling modal from <a> tag

Is it possible to call a modal from an <a> tag? This is the snippet of my code
@else
{{ $section->label }}
<a href="#"
wire:click.prevent="editSection('{{ $section->id }}')"
class="ml-2 text-blue-500 font-light border border-blue-800 rounded px-1.5 py-0.5 hover:bg- blue-800 hover:text-white transition-colors duration-300">
Edit
</a>
@endif
@else
{{ $section->label }}
<a href="#"
wire:click.prevent="editSection('{{ $section->id }}')"
class="ml-2 text-blue-500 font-light border border-blue-800 rounded px-1.5 py-0.5 hover:bg- blue-800 hover:text-white transition-colors duration-300">
Edit
</a>
@endif
30 Replies
awcodes
awcodes5mo ago
Please don’t do this. Links and buttons are different for a reason. You can still use a button and make it look like a link.
o.m
o.mOP5mo ago
Sure I'll change it to button
awcodes
awcodes5mo ago
You can either use an action or filament’s button component if you need more control. https://filamentphp.com/docs/3.x/support/blade-components/button
o.m
o.mOP5mo ago
What do I do with openNewUserModal?
awcodes
awcodes5mo ago
That’s why I recommend using an action, the modal stuff is built in.
o.m
o.mOP5mo ago
like similar to saveAction, deleteAction etc ?
o.m
o.mOP5mo ago
Is it possible to update the ui ?
No description
o.m
o.mOP5mo ago
ahh nvm the only way i can update the Ui is through the function itself
awcodes
awcodes5mo ago
You can always change the styling through css.
o.m
o.mOP5mo ago
there is not function to let me style or use class here
public function editAction(): Action
{
return Action::make('Edit')
->requiresConfirmation()

->action(function (array $arguments) {
dd($arguments);

});
}
}
public function editAction(): Action
{
return Action::make('Edit')
->requiresConfirmation()

->action(function (array $arguments) {
dd($arguments);

});
}
}
Where should I do it?
awcodes
awcodes5mo ago
The actions have css classes that you can use to target them in your stylesheet and change them.
o.m
o.mOP5mo ago
like the theme.css ?
awcodes
awcodes5mo ago
If you need to target a specific one, iirc correctly, you can use ->extraAttribute([‘class’ => ‘my-btn’]) then target .my-btn in the stylesheet. Yes, like theme.css It’s still all just html and css. 🙂
o.m
o.mOP5mo ago
Yeah,, I was expecting to just use the extraAttribute function only
awcodes
awcodes5mo ago
Well, technically you can as long as that file is part of the tailwind config content so it gets scanned.
o.m
o.mOP5mo ago
Weird.. nothing works using extraAttribute Ahh
awcodes
awcodes5mo ago
Attributes plural. Sorry
o.m
o.mOP5mo ago
do I need to add this to Tailwind.config ? like the GroupSetting.php?
No description
o.m
o.mOP5mo ago
:/ wasn't able to get it to work
No description
awcodes
awcodes5mo ago
Or at least the path to the directory where it is. But yes. If tailwind doesn’t know to scan those files it won’t include those classes.
o.m
o.mOP5mo ago
No description
o.m
o.mOP5mo ago
Yeah added this just to make sure.
awcodes
awcodes5mo ago
I have had issues in the past though with it scanning php class files. So, in that case just use a custom class name and target it in the css file and use tailwind’s @apply rule.
o.m
o.mOP5mo ago
Yeah.. I guess . Thanks this will definitely solve the problem. Got no choice I guess..
awcodes
awcodes5mo ago
Did you restart the dev server after adding it Or run npm run build?
o.m
o.mOP5mo ago
No Just restarted it now but still doenst work
awcodes
awcodes5mo ago
Any time you change the TW config you have to either restart or rebuild.
o.m
o.mOP5mo ago
Okay noted on that
awcodes
awcodes5mo ago
Surprised it’s not working though. Sorry. Also, kinda guessing on your setup too.

Did you find this page helpful?