Vincent
Vincent
FFilament
Created by Andrew Wallo on 8/7/2023 in #❓┊help
Customizing Profile Page in Tenant Panel
Actually it's working fine! I just had a stray route helper call that wasn't including the new tenant model. oops.
7 replies
FFilament
Created by Andrew Wallo on 8/7/2023 in #❓┊help
Customizing Profile Page in Tenant Panel
Man. I’m actually not even able to access the basic Resource routes since I added tenancy to my panel. Like {tenant}/location/create results in the same error.
7 replies
FFilament
Created by Andrew Wallo on 8/7/2023 in #❓┊help
Customizing Profile Page in Tenant Panel
@Andrew Wallo Hi! Did you ever find a way to work with this? I'm seeing the same problem using the Spatie roles and permissions package.
7 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
After a consulting call with @Zep Fietje (well worth the money -- thanks for the help!), I ended up using a searchable Select component from Filament. It did what I tried to cobble together above, but with a better experience overall. If I need to customize the input template more in the future, I'll have to remember that the backend/Livewrie functionality is handled by the parent's Livewire component, not the input itself. So instead of e.g. instantiating a TextInput in the form's context, I'd just use the x-filament::input component directly in my custom field's template, and have it call Livewire functionality by adding the Livewire methods to the parent component (Page, Form, etc.). (Filament's Select input is a great example of how this might be done.)
16 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
Yeah the new Laracasts course really helped me wrap my head around it! It's using some pretty cool PHP trickery under the hood. It feels like it must be possible, but I'm under a deadline and done is better than perfect. Gonna sleep on it & see where I land tomorrow. Meantime, I'll mark this as solved, but hopefully somebody else can chime in as well. Thanks again!
16 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
@awcodes Thanks for the input. I get the impression I'm fighting the framework pretty hard! Other plugins seem to re-create Filament markup pretty liberally, so I guess that's what I'll do too.
16 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
The only thing that seems to work if I'm doing this as a custom field with children is to explicitly set the inputs as children via getChildComponents -- but that means I lose the ability to control each input individually in the view.
16 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
Hmm...this doesn't seem to make a difference, whether I add it to the parent or the child.
16 replies
FFilament
Created by Vincent on 9/19/2023 in #❓┊help
Is there a good way to compose fields together in a Custom Field?
// ...
public function getTextInput(): TextInput
{
return TextInput::make($this->getId())
->label($this->getLabel())
->helperText($this->getHelperText())
->statePath($this->getQueryStatePath())
->container($this->getContainer())
->afterStateUpdated(function (?string $state, Set $set) {
$client = $this->getClient();

if (blank($state)) {
$this->datalist([]);
$set($this->statePath, '');

return;
}

$this->datalist(
collect($client->autoComplete($state))
->flatMap(fn (array $prediction) => [
$prediction['place_id'] => $prediction['description']
])
);
})
->required()
->debounce();
}

public function getRadioInput(): Radio
{
return Radio::make($this->getStatePath())
->container($this->getContainer())
->label(function (Get $get): string {
if (filled($get($this->getQueryStatePath())) && blank($this->getDatalistOptions())) {
return $this->getEmptyResultsLabel();
}

return $this->getResultsLabel();
})
->options(fn (): array => $this->getDatalistOptions() ?? [])
->hidden(fn (Get $get): bool => blank($get($this->getQueryStatePath())));
}
// ...
public function getTextInput(): TextInput
{
return TextInput::make($this->getId())
->label($this->getLabel())
->helperText($this->getHelperText())
->statePath($this->getQueryStatePath())
->container($this->getContainer())
->afterStateUpdated(function (?string $state, Set $set) {
$client = $this->getClient();

if (blank($state)) {
$this->datalist([]);
$set($this->statePath, '');

return;
}

$this->datalist(
collect($client->autoComplete($state))
->flatMap(fn (array $prediction) => [
$prediction['place_id'] => $prediction['description']
])
);
})
->required()
->debounce();
}

public function getRadioInput(): Radio
{
return Radio::make($this->getStatePath())
->container($this->getContainer())
->label(function (Get $get): string {
if (filled($get($this->getQueryStatePath())) && blank($this->getDatalistOptions())) {
return $this->getEmptyResultsLabel();
}

return $this->getResultsLabel();
})
->options(fn (): array => $this->getDatalistOptions() ?? [])
->hidden(fn (Get $get): bool => blank($get($this->getQueryStatePath())));
}
...and the view (not much HTML yet):
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
{!! $getTextInput()->toHtml() !!}
{!! $getRadioInput()->toHtml() !!}
</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
{!! $getTextInput()->toHtml() !!}
{!! $getRadioInput()->toHtml() !!}
</div>
</x-dynamic-component>
Using getChildComponents seems to work, but then I'm limited in the amount of custom HTML I can write. I literally just want to wrap the Radio inputs directly below the Text input.
16 replies
FFilament
Created by GeRaged | Niklas on 9/8/2023 in #❓┊help
Unable to call component method. Public method [setValue] not found on component
I have to read the docs more closely -- didn't know about $get and $set. FWIW I'm writing a wizard with a text input that's an autocomplete/search field. It hits an API on update and populates a radio group below with the results from the API call. I can start a new thread if I run into more hiccups, I know this one's getting a little long. Thanks for all your help!
22 replies
FFilament
Created by GeRaged | Niklas on 9/8/2023 in #❓┊help
Unable to call component method. Public method [setValue] not found on component
me, a developer, overcomplicate things? impossible
22 replies
FFilament
Created by GeRaged | Niklas on 9/8/2023 in #❓┊help
Unable to call component method. Public method [setValue] not found on component
Got it! Thanks for clarifying. That means Alpine's $wire (in e.g. a Custom Field) will always refer the parent Livewire component, and that's how we can manipulate livewire state inside nested fields, yeah? So we might not need a nested Livewire component
22 replies
FFilament
Created by GeRaged | Niklas on 9/8/2023 in #❓┊help
Unable to call component method. Public method [setValue] not found on component
(I could also be super confused here, trying to build a dynamic custom field)
22 replies
FFilament
Created by GeRaged | Niklas on 9/8/2023 in #❓┊help
Unable to call component method. Public method [setValue] not found on component
Sorry to bump an old thread -- I actually just ran into this. The docs for Custom Fields seem to imply that individual fields are Livewire components, but doesn't explicitly say "this is not a livewire component, just a Blade component". For instance, it says:
This is the basis of how fields work in Filament. Each field is assigned to a public property in the Livewire component class, which is where the state of the field is stored. We call the name of this property the "state path" of the field.
I'm guessing the "Livewire component class" here is whatever context the Custom Field appears in (e.g. a Page, Widget, etc.)?
22 replies
FFilament
Created by Vincent on 8/29/2023 in #❓┊help
TextColumn placeholder empty
Docs make it seem like placeholder can be used instead of the ternary I was using before, but I guess not. Anywho -- thank you for your suggestion!
15 replies
FFilament
Created by Vincent on 8/29/2023 in #❓┊help
TextColumn placeholder empty
Yep I saw that in your issue -- maybe the docs just need to be updated?
15 replies
FFilament
Created by Vincent on 8/29/2023 in #❓┊help
TextColumn placeholder empty
Thanks for the suggestion, I didn't know about default. default and placeholder feel semantically different, though: default provides a default value, which then gets passed to any formatters. So, doing the following:
TextColumn::make('cost_usd')
->label('Cost')
->default('In progress')
->money('usd'),
TextColumn::make('cost_usd')
->label('Cost')
->default('In progress')
->money('usd'),
results in an exception, because money requires a number, not a string -- but In progress is a string.
15 replies
FFilament
Created by Vincent on 8/29/2023 in #❓┊help
TextColumn placeholder empty
Ah that makes sense! Hadn't found any similar issues on github, must have just missed it. Let me know if I can help reproduce or debug!
15 replies
FFilament
Created by Vincent on 8/29/2023 in #❓┊help
TextColumn placeholder empty
You know what's weird? I was using that exact ternary before the upgrade and it worked; now, though, the cell is still blank even if the short function returns a different string. I'd thought the same thing re: the string format never truly being empty, but even just returning $state with the placeholder doesn't do the trick. The money method is cool, didn't know about it! Placeholder still blank though.
15 replies