Vincent
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
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
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
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
Is there a good way to compose fields together in a Custom Field?
...and the view (not much HTML yet):
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
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
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 component22 replies
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
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:
results in an exception, because money
requires a number, not a string -- but In progress
is a string.15 replies
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