ThatWebGuy
ThatWebGuy
FFilament
Created by ThatWebGuy on 9/16/2024 in #❓┊help
Reusable component with multiple form input fields
Hey Everyone, I’m trying to figure out how I can create a reusable component that I can use on multiple resources without having to type the same items over an over. I want to create a component called “Link” with the following fields.
Select::make(‘type),
TextInput::make(‘internal’),
Select::make(‘internal’),
TextInput::make(‘external’),
TextInput::make(‘email’),
TextInput::make(‘phone’),
Select::make(‘target’)
Select::make(‘type),
TextInput::make(‘internal’),
Select::make(‘internal’),
TextInput::make(‘external’),
TextInput::make(‘email’),
TextInput::make(‘phone’),
Select::make(‘target’)
6 replies
FFilament
Created by ThatWebGuy on 8/4/2024 in #❓┊help
Dynamic label for repeaters
Is there a way that I can give a dynamic label to each item in my repeater? Currently when i set the "label" it sets a top level label but each item in the repeater has a blank bar between the order and delete icons.
3 replies
FFilament
Created by ThatWebGuy on 6/25/2024 in #❓┊help
Repeatable content based on template selected
Hey Everyone, I followed a trick on the site for “Template based forms” but I’m wanting to modify it so that my repeatable content area is populated based on the template selected. Article: Template Based Forms I created 4 page templates based off of the example in the article but I also added a protected array $layouts = [‘homepage’, ‘page’]; where I want to specify what templates the page templates are available on. On my PageResource.php file, I have declared the following for the form.
php
Return $form
->columns(3)
->schema([
Tabs::make()
->columnSpan(2)
->tabs([
Tab::make(‘Content’)
->schema([
Repeater::make(‘content’)
->schema([])
])
])
Section::make()
->schema([
Select::make(‘layout’)
->options([
‘homepage’ => ‘Homepage’,
‘page’ => ‘Standard Page’
])
])
])
php
Return $form
->columns(3)
->schema([
Tabs::make()
->columnSpan(2)
->tabs([
Tab::make(‘Content’)
->schema([
Repeater::make(‘content’)
->schema([])
])
])
Section::make()
->schema([
Select::make(‘layout’)
->options([
‘homepage’ => ‘Homepage’,
‘page’ => ‘Standard Page’
])
])
])
Could anyone help me fix this.
2 replies
FFilament
Created by ThatWebGuy on 4/3/2024 in #❓┊help
Update each repeater field 2 fields outside the repeater
I'm playing around with creating a invoice in Filament and I've created a form that has multiple fields outside a repeater and then a repeater that has multiple items inside it. After a change is made in any of the repeater fields, I need to update that that specific repeater item. But then I also want to update a few fields outside the repeater. Currently what I have is not working and I'm not quite sure why it's not. I'm sure it's in regards to the repeater items.
public static function form(Form $form): Form
{
Repeater::make('items')
->schema([
TextInput::make('title'),
TextInput::make('qty')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('rate')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('discount')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('line_total')
->live(),
]),
TextInput::make('subtotal')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('discount')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('tax')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('total')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
}
public static function form(Form $form): Form
{
Repeater::make('items')
->schema([
TextInput::make('title'),
TextInput::make('qty')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('rate')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('discount')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('line_total')
->live(),
]),
TextInput::make('subtotal')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('discount')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('tax')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('total')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
}
2 replies
FFilament
Created by ThatWebGuy on 8/19/2023 in #❓┊help
Form fails when inside createOptionForm but works when it's on it's own page
I have taken my basic user form with a select for roles. When I recreate this form in the createOptionsForm, the select for roles fails. Has anyone else run into this?
4 replies
FFilament
Created by ThatWebGuy on 8/13/2023 in #❓┊help
Searchable TextInput Field
Hi Everyone. I was playing with Filament and starting tinkering around with creating an Invoice Resource. Everything has been going good but I was wondering if it's possible to make a TextInput field be searchable like a Select. I was wanting to make is so that I could type in reuseable item titles and select one and have it prefill the rest of the invoice item out, if not, then save the name as the invoice row item. Currently I have a Select for "manual" or "reuseable" with specific fields hidden/shown based on what's selected. This works fine, but if I could accomplish the searchable text input, that would be awesome.
3 replies
FFilament
Created by ThatWebGuy on 8/12/2023 in #❓┊help
CMS-Pages with Filament V3
I know CMS-Pages isn't compatible with v3 of Filament but I've been trying to recreate it based on its Github repo. The issue I'm running into is that when I select the template for the page, it doesn't show the additional fields from the template file. Anyone play around with this already?
14 replies
FFilament
Created by ThatWebGuy on 8/6/2023 in #❓┊help
Saving related items when editing/creating a resource
Hi Everyone, I'm trying to setup so that when I'm on the create/edit screen of my resource, I can add multiple items with a repeater and upon saving, those additional items are saved to their corresponding table. ClientResource.php Form
Repeater::make('contacts')
->relationship()
->schema([])
Repeater::make('contacts')
->relationship()
->schema([])
Client Model
public function contacts() {
return $this->hasMany(Contact::class);
}
public function contacts() {
return $this->hasMany(Contact::class);
}
When the client resource creation runs, it creates the client item but doesn't create the contact(s).
17 replies