cigoler
cigoler
FFilament
Created by cigoler on 9/14/2023 in #❓┊help
simplePaginate core component loading indicator always on
No description
2 replies
FFilament
Created by cigoler on 8/15/2023 in #❓┊help
KeyValue collapsing before can add a row
Strange behaviour with a KeyValue form component collapsing before I can add a new row. It has a relevant JSON field that's casted correctly as an array as well.
6 replies
FFilament
Created by cigoler on 8/14/2023 in #❓┊help
Is it possible for the form Wizard to show only the current step your on?
3 replies
FFilament
Created by cigoler on 4/27/2023 in #❓┊help
action button on form elements like textarea, is it possible?
On textinputs we've got suffix and prefix but (unless I'm mistaken) they don't work on textarea, is there any way around this? For example to just have a button to the size of it that if you click it empties the textarea (resets it).
2 replies
FFilament
Created by cigoler on 4/24/2023 in #❓┊help
createOptionForm - how to import form schema, is it possible?
I'm using a separate form schema to try and cut down on repetition and mistakes, and so far so good it imports and seems to work:
protected function getFormSchema(): array
{
return \App\FormSchemas\UserFormSchema::schema();
}
protected function getFormSchema(): array
{
return \App\FormSchemas\UserFormSchema::schema();
}
As part of that schema I want there to be a createOptionForm on one of the drop down selects that imports the schema from yet another file (
\App\FormSchemas\CategoryFormSchema::schema()
\App\FormSchemas\CategoryFormSchema::schema()
):
Card::make()
->schema([
Forms\Components\Select::make('category_id')
->options(Category::all()->pluck('name', 'id'))
->required()
->createOptionForm([

]),
]),
Card::make()
->schema([
Forms\Components\Select::make('category_id')
->options(Category::all()->pluck('name', 'id'))
->required()
->createOptionForm([

]),
]),
But I'm not sure what I can pass to createOptionForm to make it work, I've tried a bunch of stuff like throwing darts at a board and got nowhere. I've tried:
->createOptionForm(function () {
return \App\FormSchemas\CategoryFormSchema::schema();
}),
->createOptionForm(function () {
return \App\FormSchemas\CategoryFormSchema::schema();
}),
Which doesn't throw an error like other options, but when clicking the button nothing happens... is it not possible to nest these imports?
15 replies
FFilament
Created by cigoler on 4/19/2023 in #❓┊help
Edit Form multiselect with Spatie laravel-Permission - Struggling to get it to work
Continuing on from Chat, where I can't get the default relationship method to work on the select I've got this at least opening up with the right roles already assigned - but searching for and selecting any others the names change to id numbers and clicking submit does not save any changes.
class Edit extends Component implements Forms\Contracts\HasForms
{
use Forms\Concerns\InteractsWithForms;

public User $user;

public $name = '';
public $slug = '';
public $email = '';
public $job_title = '';
public $active;
public $roles = [];

public function mount(): void
{
$this->form->fill([
'name' => $this->user->name,
'slug' => $this->user->slug,
'email' => $this->user->email,
'roles' => $this->user->roles->pluck('name')->toArray(),
]);
}
class Edit extends Component implements Forms\Contracts\HasForms
{
use Forms\Concerns\InteractsWithForms;

public User $user;

public $name = '';
public $slug = '';
public $email = '';
public $job_title = '';
public $active;
public $roles = [];

public function mount(): void
{
$this->form->fill([
'name' => $this->user->name,
'slug' => $this->user->slug,
'email' => $this->user->email,
'roles' => $this->user->roles->pluck('name')->toArray(),
]);
}
Forms\Components\Select::make('roles')
->searchable()
->multiple()
->getSearchResultsUsing(fn (string $query) => Role::where('name', 'like', "%{$query}%")->limit(50)->pluck('name', 'id'))
->getOptionLabelUsing(fn ($value): ?string => Role::find($value)?->name)
->label('Roles assigned')
->helperText('Select roles to assign to this user.'),
Forms\Components\Select::make('roles')
->searchable()
->multiple()
->getSearchResultsUsing(fn (string $query) => Role::where('name', 'like', "%{$query}%")->limit(50)->pluck('name', 'id'))
->getOptionLabelUsing(fn ($value): ?string => Role::find($value)?->name)
->label('Roles assigned')
->helperText('Select roles to assign to this user.'),
public function submit()
{
$this->user->update(
$this->form->getState(),
);

Notification::make()
->title('Updated successfully')
->body($this->user->name.' successfully updated in database.')
->success()
->send();

return redirect()->route('users.show', $this->user);
}
public function submit()
{
$this->user->update(
$this->form->getState(),
);

Notification::make()
->title('Updated successfully')
->body($this->user->name.' successfully updated in database.')
->success()
->send();

return redirect()->route('users.show', $this->user);
}
This
7 replies