Comments (11)
wtf, i've acidentally edited your comment instead of adding a new one. sorry.
You cannot pass the $record instance as a third parameter, because it does not exist
@ousid I think the function definition is outdated?
https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Testing/TestsActions.php#L575
I may be wrong, i'm not too much into tests, i'm source diving rn to help you. Just wanted to correct the comment from @dmitry-udod
from filament.
@ousid Hi! Yes, the bug is indeed present, but only in tests. Seems it's happen because you use $record variable name and this is like a reserved word here
But you can avoid this bug to change code from:
->actions([
...
Tables\Actions\EditAction::make()
->url(
fn (Model $record) => 'https://filamentphp.com'
),
...
]),
To
->actions([
...
Tables\Actions\EditAction::make()
->url(
fn (User $user) => 'https://filamentphp.com'
),
...
]),
Screencast.2024-04-18.14.31.03.mp4
from filament.
But you can avoid this bug to change code from: ...
Changing Model $record
to User $user
would break the application if the closure needs the record. $record
is a named evaluation parameter, if renamed, it would never be resolved, thats why the error is gone.
@ousid, you need to pass the $record as the third parameter to assertTableActionHasUrl()
from filament.
wtf, i've acidentally edited your comment instead of adding a new one. sorry.
You cannot pass the $record instance as a third parameter, because it does not exist
@ousid I think the function definition is outdated? https://github.com/filamentphp/filament/blob/3.x/packages/tables/src/Testing/TestsActions.php#L575
I may be wrong, i'm not too much into tests, i'm source diving rn to help you. Just wanted to correct the comment from @dmitry-udod
Oh. Thanks for catching that!
from filament.
The only things remain, is why the
.stub
didn't get updated? Or I'm missing something?
It can happen, maybe a conflicted merge result or something.
from filament.
The only things remain, is why the
.stub
didn't get updated? Or I'm missing something?It can happen, maybe a conflicted merge result or something.
I was thinking about closing this issue (since it's not an issue anymore) But I'll keep it open for this reason, till the maintainers decided how to resolve this one.
I'll be happy to open a PR to update the .stubs
file, if you want me to!
Note: Even the docs, missing this part (https://filamentphp.com/docs/3.x/tables/testing#url)
from filament.
Go for it!
from filament.
@ousid Hi! Yes, the bug is indeed present, but only in tests. Seems it's happen because you use $record variable name and this is like a reserved word here
But you can avoid this bug to change code from:
->actions([ ... Tables\Actions\EditAction::make() ->url( fn (Model $record) => 'https://filamentphp.com' ), ... ]),
To
->actions([ ... Tables\Actions\EditAction::make() ->url( fn (User $user) => 'https://filamentphp.com' ), ... ]),
Screencast.2024-04-18.14.31.03.mp4
Yes, the error is gone, but the example here, is just for demonstrating the shown error, in the real app, I'm developing, I need to pass the record
var, as it is, to get the actual data. It's like something like this:
EditAction::make()
->color('success')
->url(
fn (?Article $record) => route('articles.edit', $record?->getSlug())
),
PS: I'm using the tables package outside the panel.
from filament.
@ousid, you need to pass the $record as the third parameter to assertTableActionHasUrl()
You cannot pass the $record instance as a third parameter, because it does not exist
https://github.com/filamentphp/filament/blob/3.x/packages/tables/.stubs.php#L100
from filament.
wtf, i've acidentally edited your comment instead of adding a new one. sorry.
No worries, It happens
@ousid I think the function definition is outdated?
Not sure, will try it out, and let you know. I'm using the latest release, tho.
Update
Yes, you are right. I passed the model, and the test passes.
The only things remain, is why the .stub
didn't get updated? Or I'm missing something?
from filament.
Please open a PR to make the stubs consistent if you wish
from filament.
Related Issues (20)
- Ability to disable the avatar/user menu on registration flow
- Checkboxes in a CheckboxList, when included in a Wizard step, toggles all checkboxes in the group regardless of the one toggled HOT 2
- Cannot append assets after Filament's unless using `PackageServiceProvider` by Spatie HOT 9
- `->keyBindings(['mod+enter'])` only works once HOT 2
- Wizard Step after step 2 gets `overflow-hidden` class on expanded collapsible container
- php artisan filament:install --panels php:63: command not found: admin HOT 1
- Repeater won't send values to database when 2 or more fields are inside the repeater.(i've to use same name as the input's name but how can i name them when 2 or more fields are there?) HOT 4
- The POST method is not supported for route admin/login HOT 1
- InteractsWithPageTable does not work when used on a nested resource page
- Form input select does not work with disabled() and searchable() at the same time. HOT 1
- 2FA HOT 1
- Don't validate dehydrated(false) fields by default
- JS-powered hidden/visible control
- simplePaginated() and cursorPaginated() methods on the table for easier control
- Move to Alpine.js sortable plugin
- ->preserveDataWhenCreatingAnother(['name'])
- Access data from parent action in nested action
- Investigate switching to local Inter or system font
- Investigate asset registration in boot() only
- Detach/Delete configureUsing not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filament.