backtrackjack
backtrackjack
FFilament
Created by backtrackjack on 10/4/2023 in #❓┊help
`->hidden()` method on TextInput field breaks app
but that sounds right, if it won't let me create with hidden on. thanks
5 replies
FFilament
Created by backtrackjack on 10/4/2023 in #❓┊help
`->hidden()` method on TextInput field breaks app
full stack trace
5 replies
FFilament
Created by backtrackjack on 9/8/2023 in #❓┊help
autofocus() not working
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')->required()->maxLength(255)
->extraAlpineAttributes([
'x-ref' => 'matter-title-input',
'@focus-matter-title-input.window' => '$nextTick(() => { $refs.matter-title-input.focus(); } )',
]),
Hidden::make('owner_id')->default(auth()->id()),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')->required()->maxLength(255)
->extraAlpineAttributes([
'x-ref' => 'matter-title-input',
'@focus-matter-title-input.window' => '$nextTick(() => { $refs.matter-title-input.focus(); } )',
]),
Hidden::make('owner_id')->default(auth()->id()),
]);
}
6 replies
FFilament
Created by backtrackjack on 9/8/2023 in #❓┊help
autofocus() not working
however trying to do it on a panel page doesn't seem to work the same way. I feel like it has something to do with the lifecycle hooks timing?
class ListMatters extends ListRecords
{
protected static string $resource = MatterResource::class;

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->disableCreateAnother()
->afterFormFilled(function() {
$this->dispatchBrowserEvent('focus-matter-title-input');
})
->after(fn (Model $record) => redirect("/matters/$record->id")),
];
}
}
class ListMatters extends ListRecords
{
protected static string $resource = MatterResource::class;

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->disableCreateAnother()
->afterFormFilled(function() {
$this->dispatchBrowserEvent('focus-matter-title-input');
})
->after(fn (Model $record) => redirect("/matters/$record->id")),
];
}
}
6 replies
FFilament
Created by backtrackjack on 9/8/2023 in #❓┊help
autofocus() not working
My solution on a custom component that uses filament forms is this:
//in form schema
TextInput::make('...')
->extraAlpineAttributes([
'x-ref' => 'input',
'@focus-input.window' => '$nextTick(() => { $refs.input.focus(); } )',
])

//callback of action button
public function doAction()
{
//perform action
//...
$this->dispatchBrowserEvent('focus-input');
}
//in form schema
TextInput::make('...')
->extraAlpineAttributes([
'x-ref' => 'input',
'@focus-input.window' => '$nextTick(() => { $refs.input.focus(); } )',
])

//callback of action button
public function doAction()
{
//perform action
//...
$this->dispatchBrowserEvent('focus-input');
}
6 replies
FFilament
Created by backtrackjack on 9/8/2023 in #❓┊help
autofocus() not working
both create and edit actions produce modal forms as intended, just the autofocus isn't focusing
6 replies
FFilament
Created by backtrackjack on 8/24/2023 in #❓┊help
Dynamic Form Field
This was my solution. Couldn't get the filament forms event to work
6 replies
FFilament
Created by backtrackjack on 8/24/2023 in #❓┊help
Dynamic Form Field
return [
TextInput::make('activeTopicTitleInput')
->extraAttributes([
'x-show' => 'editMode',
])
->columnSpanFull()
->required()
->disableLabel()
->prefix('Fact Topic')
->lazy()
->afterStateUpdated(function ($state) {
$this->validateOnly('activeTopicTitleInput');
$this->activeTopic->update([
'title' => $state,
]);
}),
Placeholder::make('activeTopicTitlePlaceholder')
->disableLabel()
->extraAttributes(function () {
$attributes = [
'class' => 'text-2xl',
'x-show' => 'courtMode',
];
if ($this->editMode) {
$attributes['style'] = 'display: none;';
}

return $attributes;
})
// value is based on the activeTopicTitleInput form field
->content(fn (Closure $get) => $get('activeTopicTitleInput')),

return [
TextInput::make('activeTopicTitleInput')
->extraAttributes([
'x-show' => 'editMode',
])
->columnSpanFull()
->required()
->disableLabel()
->prefix('Fact Topic')
->lazy()
->afterStateUpdated(function ($state) {
$this->validateOnly('activeTopicTitleInput');
$this->activeTopic->update([
'title' => $state,
]);
}),
Placeholder::make('activeTopicTitlePlaceholder')
->disableLabel()
->extraAttributes(function () {
$attributes = [
'class' => 'text-2xl',
'x-show' => 'courtMode',
];
if ($this->editMode) {
$attributes['style'] = 'display: none;';
}

return $attributes;
})
// value is based on the activeTopicTitleInput form field
->content(fn (Closure $get) => $get('activeTopicTitleInput')),

6 replies
FFilament
Created by backtrackjack on 8/24/2023 in #❓┊help
Dynamic Form Field
ok I realise the refresh component is happening before the mode is actually changed. My new approach is to add a registerListeners() on each field that listens for some 'modeChanged' event.
6 replies
FFilament
Created by backtrackjack on 8/24/2023 in #❓┊help
Dynamic Form Field
protected function getFactTopicFormSchema(): array
{
return [
Placeholder::make('activeTopicTitle')
->disableLabel()
->extraAttributes(['class' => 'text-2xl overflow-ellipsis'], true)
->content($this?->activeTopic?->title)
->visible(function () {
return tap($this->courtMode, fn() => $this->emitSelf('refreshComponent'));
}),
TextInput::make('activeTopicTitle')
->visible(function () {
return tap($this->editMode, fn() => $this->emitSelf('refreshComponent'));
})
->columnSpanFull()
->required()
->disableLabel()
->prefix('Fact Topic')
->lazy()
->afterStateUpdated(function ($state) {
$this->validateOnly('activeTopicTitle');
$this->activeTopic->update([
'title' => $state,
]);
}),
];
}
protected function getFactTopicFormSchema(): array
{
return [
Placeholder::make('activeTopicTitle')
->disableLabel()
->extraAttributes(['class' => 'text-2xl overflow-ellipsis'], true)
->content($this?->activeTopic?->title)
->visible(function () {
return tap($this->courtMode, fn() => $this->emitSelf('refreshComponent'));
}),
TextInput::make('activeTopicTitle')
->visible(function () {
return tap($this->editMode, fn() => $this->emitSelf('refreshComponent'));
})
->columnSpanFull()
->required()
->disableLabel()
->prefix('Fact Topic')
->lazy()
->afterStateUpdated(function ($state) {
$this->validateOnly('activeTopicTitle');
$this->activeTopic->update([
'title' => $state,
]);
}),
];
}
6 replies
FFilament
Created by vahnmarty on 6/12/2023 in #❓┊help
How to customize Repeater form events?
I ran into the same problem. dd() does not fire when I create a protected function setUp() with $this->registerListeners while listening for any repeater::x event but it works when I add the registerListeners() method to the repeater field
10 replies
FFilament
Created by backtrackjack on 7/19/2023 in #❓┊help
Livewire + Alpine optimisation
3 replies
FFilament
Created by backtrackjack on 6/28/2023 in #❓┊help
How can I get this functionality on a TagsColumn
12 replies
FFilament
Created by backtrackjack on 6/28/2023 in #❓┊help
How can I get this functionality on a TagsColumn
actually I'm intrigued. Because the Role model comes from a package, can I still create an accessor for it easily? maybe there's a vendor publish thing for it.
12 replies
FFilament
Created by backtrackjack on 6/28/2023 in #❓┊help
How can I get this functionality on a TagsColumn
ah of course, this getStateUsing works well for now but I'll keep it in mind cheers!
12 replies
FFilament
Created by backtrackjack on 6/28/2023 in #❓┊help
How can I get this functionality on a TagsColumn
do you mean store roles as an attribute instead of a relation? I'm using the filament-shield plugin that makes a seperate model for roles.
12 replies
FFilament
Created by backtrackjack on 6/28/2023 in #❓┊help
How can I get this functionality on a TagsColumn
life saver thanks!
12 replies