low-res (Paul)
low-res (Paul)
FFilament
Created by low-res (Paul) on 7/24/2023 in #❓┊help
unique validation on soft-deleted records
Hi experts, I have a simple form for users. The email address should be unique. The users Model uses soft-deletes. The formfield for email looks like this: TextInput::make('email') ->rules(['required', 'email']) ->unique( ignoreRecord: true ) ->placeholder('Email') This all works fine until I delete a user and want to create a new user with the same email as the deleted user. In plain Laravel controller I could do something like: 'email' => 'unique:user,email,{$userId},id,deleted_at,NULL' What would be the equivalent in my filament form? Thx for help!
8 replies
FFilament
Created by low-res (Paul) on 6/26/2023 in #❓┊help
CheckboxList value is always a single value?!
Hi experts! Another Beginer-Question 🙂 I have a Dashboard-Widget that hosts a form. So it implements HasForms and uses the trait InteractsWithForms My form looks something like this: protected function getFormSchema(): array { $countryCodes = ['DE' => 'DE', 'FR' => 'FR', 'CN' => 'CN'] ; return [ CheckboxList::make('origin') ->options( $countryCodes ) ->bulkToggleable(true) ->columns(3), CheckboxList::make('destination') ->options( $countryCodes ) ->bulkToggleable(true) ->columns(3), ]; } All Formdata is written to public property $data protected function getFormStatePath(): string { return 'data'; } My problem is, that any of the CheckboxLists always contains just one option as value, even if all checkboxes are selected. It doesn't matter if I get the form values with $this->form->getState() or via $this->data . So my question is: How do I get ALL values of the selected checkboxes? (as a JSON string or an array.)
5 replies
FFilament
Created by low-res (Paul) on 6/26/2023 in #❓┊help
How to test table with filter form
Hi Experts. I have a table component with a pretty complex filterform. Everything is running well. Now I want to write some tests for this tablecomponent to make sure all my filters are working correctly. The relevant parts of the tabledefinition in the resource looks like this: return $table ->columns( ... ) ->filters([ Filter::make('Filter')->columnSpan(12)->form([ Grid::make(['default' => 12])->schema([ Section::make('fixed_section') ->columnSpan(12) ->schema([ Grid::make(5)->schema([ TextInput::make('hawb'), ... ]) ]) ->query(function (Builder $query, array $data): Builder { ... }) ]) ->filtersLayout(Layout::AboveContent) ->actions([]) ->bulkActions([]); In my test I am doing something like this: Livewire::test(ListShipments::class) ->assertCanSeeTableRecords( $allShipments ) ->filterTable('hawb', 'XYZ') ->assertCanSeeTableRecords( $specificShipments ); When I run the test I get the following Error message: Failed asserting that a table filter with name [hawb] exists on the [App\Filament\Resources\ShipmentResource.... So I assume to set a value in the filter form I need to use something different then ->filterTable('hawb', 'XYZ') ?! How do I interact with the filterform of my tablecomponent in a test? Any tipps very appreciated!
8 replies