Setting a card-headline

Quick one (hopefully) - I'm trying to use the Card-Component via Card::make() which I wanna use to create a custom card. How do I set the headline for said card? ->label seems not do to the trick...
23 Replies
Patrick Boivin
I think Card doesn't have a title but Section does
Husky110
Husky110OP2y ago
Yep! That works - thank you. 🙂 To not open again a thread - I have two more questions concerning custom-view-components. 1.) Is using ->viewdata(['variable' => $variable]) the intended way to send data to a custom component or am I doing unnecessary stuff here? 2.) Is it "good" practice to use <x-filament::whatever>-calls inside my custom view component or is this disencouraged?
Patrick Boivin
I don't really know about best practices tbh but I can say that I use both viewdata() and filament blade components extensively
Andrew Wallo
Andrew Wallo2y ago
I’m pretty sure cards have headings and a header. Unless there is a difference between the Card widget and just a card.
Husky110
Husky110OP2y ago
Interestingly - I can set a heading when I use the <x-filament::card>-component inside a view, but not via Card::make. Well - since you use filament longer than I do, I guess it ain't that wrong. 😄 Thank you. 🙂
Andrew Wallo
Andrew Wallo2y ago
Have you tried using “protected function getHeader()” or “protected function getHeading()” in the class?
Husky110
Husky110OP2y ago
Won't work here, since the card is used only as a partial within a Grid.
Andrew Wallo
Andrew Wallo2y ago
Oh yeah
Husky110
Husky110OP2y ago
Right now I'm sort of abusing the form-builder to build pages that have the only purpose of displaying informations... Which is a bit confusing for newbies to the project, since I would guess that using getFormSchema is the way to do it, but to have a function like getPageSchema which basically does the same, but has a different wording makes the code more easy to read. But that would be a comfort-feature I guess... 😄
Andrew Wallo
Andrew Wallo2y ago
Regarding this question about using x-filament components in your view, i think that is fine because Filament does the same thing and plugins as well.
Husky110
Husky110OP2y ago
Thanks for that - I was scared that it might be disencouraged, since updates on said components could break stuff (like publishing the views is disencouraged for said reason). 🙂
Andrew Wallo
Andrew Wallo2y ago
If they change the view in the future you will just have to manually update it is all
Husky110
Husky110OP2y ago
Possibly. I think v3 will cause another rewrite anyhow... Seems like bad timing on starting with filament... 😄
Andrew Wallo
Andrew Wallo2y ago
Perhaps but all of us will have to rewrite things anyway, so your not alone.
Husky110
Husky110OP2y ago
Yay - shared suffering... Thanks... I guess? 🤣
Andrew Wallo
Andrew Wallo2y ago
Haha I wouldn’t say it’s suffering though, just necessary and tedious… but that’s what coding is all about anyway
Husky110
Husky110OP2y ago
especially when you write your own SaaS... 😄
Andrew Wallo
Andrew Wallo2y ago
Yes especially when using 3rd party libraries and dependencies
Husky110
Husky110OP2y ago
Yep - But I come from "building everything on my own" and I think there it is worse sometimes. Good thing is that I'm running everything on docker, so even if there is a break somewhere - I can fall back on a working image. 🙂
Andrew Wallo
Andrew Wallo2y ago
That’s good. Never really used docker. I usually just build and code locally as a hobby. But yeah “building everything on your own” is more work, but over time I have started to realize the more complex and highly specialized type of software application you have or want to build… building on your own is almost always necessary unfortunately.
Husky110
Husky110OP2y ago
You should really look into docker. It solves so many problems that occure on bare-metal (like what happens when one of your dependencies broke?) - even tho podman seems like a better way to start at the moment. Of course you have to build your own stuff - otherwise AI could just replace us... 😄 Conversation moved to DMs. Ticket itself is resolved. Thanks people. 🙂 Uh - still got one more: Is there an easy way to pass an Icon to the Heading-Parameter aswell?
Patrick Boivin
You can use the icon method on the Section:
Section::make('My Section')
->icon('heroicon-o-pencil')
// ...
Section::make('My Section')
->icon('heroicon-o-pencil')
// ...
Husky110
Husky110OP2y ago
Thank you! 😃
Want results from more Discord servers?
Add your server