pimousse7928
pimousse7928
FFilament
Created by pimousse7928 on 9/17/2023 in #❓┊help
Action refresh Select field value
Hello, I'm building an action and trying to refresh the select field but I cannot make it work, can someone point me out how to do that?
->action(function (array $data, Program $record, Select $component): void {
$statePath = $component->getStatePath();

$data['entity']['type'] = 'organizer';
$entity = Entity::create($data['entity']);

$users = !empty($data['users']) ? $data['users'] : [];
foreach ($users as $user) {
$user = User::create($user);
}

$record->entity()->associate($entity->id);
$record->save();

/** @var LivewireComponent $livewire */
$livewire = $component->getLivewire();
$livewire->dispatch('filament-forms::select.refreshSelectedOptionLabel', livewireId: $livewire->getId(), statePath: $statePath);

})
->action(function (array $data, Program $record, Select $component): void {
$statePath = $component->getStatePath();

$data['entity']['type'] = 'organizer';
$entity = Entity::create($data['entity']);

$users = !empty($data['users']) ? $data['users'] : [];
foreach ($users as $user) {
$user = User::create($user);
}

$record->entity()->associate($entity->id);
$record->save();

/** @var LivewireComponent $livewire */
$livewire = $component->getLivewire();
$livewire->dispatch('filament-forms::select.refreshSelectedOptionLabel', livewireId: $livewire->getId(), statePath: $statePath);

})
Thank you in advance,
3 replies
FFilament
Created by pimousse7928 on 9/10/2023 in #❓┊help
Nested Fieldset and relationship
Hello there, I have two nested fieldsets with relationship. At first save, address is not saving, however, at second save (update), address is saving correctly. I guess it's easy to understand the the first model (company) is not created so it doesn't know to which model the address should be attached. Did someone already did this? ->schema([ Forms\Components\Fieldset::make('Entreprise') ->relationship('company') ->schema([ Forms\Components\TextInput::make('name')->label('Nom'), Forms\Components\TextInput::make('identification_number')->label('Numéro SIRET'), Forms\Components\TextInput::make('sector_reference')->label('Code NAF'), Forms\Components\TextInput::make('reference')->label('Numéro partenaire'), Forms\Components\TextInput::make('vat')->label('Numéro de TVA'), Forms\Components\Fieldset::make('Adresse') ->relationship('address') ->schema([ Forms\Components\TextInput::make('address_line_1')->label('Adresse ligne 1'), Forms\Components\TextInput::make('address_line_2')->label('Adresse ligne 2'), Forms\Components\TextInput::make('city')->label('Ville'), Forms\Components\TextInput::make('postcode')->label('Code postal'), Forms\Components\TextInput::make('country')->label('Pays'), ]), ]) ]);
2 replies