F
Filament4mo ago
Eno7x

Checkbox list

Hello everyone. I have columns named "name" and "attachments" in the same table. I show the "name" field in "options()" but I don't know how to show the "attachments" field in the "descriptions" field. The "attachments" field in the table is in json format
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
])
->descriptions([
'tailwind' => 'A utility-first CSS framework for rapidly building modern websites without ever leaving your HTML.',
'alpine' => new HtmlString('A rugged, minimal tool for composing behavior <strong>directly in your markup</strong>.'),
'laravel' => str('A **web application** framework with expressive, elegant syntax.')->inlineMarkdown()->toHtmlString(),
'livewire' => 'A full-stack framework for Laravel building dynamic interfaces simple, without leaving the comfort of Laravel.',
])
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
])
->descriptions([
'tailwind' => 'A utility-first CSS framework for rapidly building modern websites without ever leaving your HTML.',
'alpine' => new HtmlString('A rugged, minimal tool for composing behavior <strong>directly in your markup</strong>.'),
'laravel' => str('A **web application** framework with expressive, elegant syntax.')->inlineMarkdown()->toHtmlString(),
'livewire' => 'A full-stack framework for Laravel building dynamic interfaces simple, without leaving the comfort of Laravel.',
])
5 Replies
toeknee
toeknee4mo ago
I think you want a repeater like #awcodes-table-repeater you can then have the checkbox on each with the columns required for that item?
Eno7x
Eno7xOP4mo ago
Thank you very much for your answer. Actually, what I want to do is this. In the 1st image, I want to show the name and attachments sections in the "CheckboxList". In the example below, I get the title of the content, but I couldn't find how to get the attachments. I know I should use a loop, but I'm very confused.
No description
No description
Eno7x
Eno7xOP4mo ago
CheckboxList::make('marineVehiclePackage')
->hiddenLabel()
->options(MarineVehiclePackage::all()->pluck('name', 'id'))
->columns(5)
->gridDirection('row')
->descriptions(MarineVehiclePackage::all()->pluck('name', 'id'))
CheckboxList::make('marineVehiclePackage')
->hiddenLabel()
->options(MarineVehiclePackage::all()->pluck('name', 'id'))
->columns(5)
->gridDirection('row')
->descriptions(MarineVehiclePackage::all()->pluck('name', 'id'))
toeknee
toeknee4mo ago
ok so
CheckboxList::make('marineVehiclePackage')
->hiddenLabel()
->options(fn() => MarineVehiclePackage::all()->pluck('name', 'id'))
->columns(5)
->gridDirection('row')
->descriptions(function() {
$values = MarineVehiclePackage::all();
$return = [];
foreach($values as $value) {
$return[$value->name] => new HtmlString( $value->description);
}
return $return;
)
CheckboxList::make('marineVehiclePackage')
->hiddenLabel()
->options(fn() => MarineVehiclePackage::all()->pluck('name', 'id'))
->columns(5)
->gridDirection('row')
->descriptions(function() {
$values = MarineVehiclePackage::all();
$return = [];
foreach($values as $value) {
$return[$value->name] => new HtmlString( $value->description);
}
return $return;
)
Like the above? you could probably ->each() on the collection for a more modern approach.
Eno7x
Eno7xOP4mo ago
Thank you very much. :pepelove: :pepelove: :pepelove:
Want results from more Discord servers?
Add your server