-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix fetching routes when there's an underscore in the field name #2905
Conversation
Nice ! However, not working on my side unfortunately. With a field customer_id : [
'label' => 'Client',
'type' => "relationship",
'name' => 'customer_id',
'entity' => 'customer',
'attribute' => 'full_name_with_company',
'ajax' => true,
'placeholder' => "Choisissez un client",
'inline_create' => [
'modal_class' => 'modal-dialog modal-lg',
]
], Result : The only solution I found is providing the right data_source manually : 'data_source' => '/site/fetch/customer', But you have to do it for every field. |
Indeed @dividy Yesterday it seemed ok to me to setup everything with field name, but well.. I was wrong. Reverted the PR to use entity again, but snake case it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pxpm should I merge this? Are you sure this a non-breaking change? |
I think as of now this will be a breaking change because everyone that setup fetch might used the I am now wondering if we need it at all (snake, or camel or kebab or whatever). The fetch "route name" comes from a function So why not Who cares about url as long as it is valid ? |
Note for future us; |
I don't 😀 What do you think now, 1 year later, @pxpm - is this worth doing in 4.2? I'd rather keep the breaking changes to a minimum. |
I still agree to doing this, but... we have enough breaking changes in 4.2 already... Since there's a reasonable and documented workaround for people who encounter this... I'm going to postpone merging this until the next major version... 😔 I've fixed the merge conflicts, though. So that it's easier for future-us to merge it. |
The inspection completed: No new issues |
Also, let's close this in favour of #3930 which does the same thing but a bit cleaner. |
The issue was raised in #2874
We were using Str::kebab to convert the function names to
url-segments
but that is not the best parser for this scenario because of function names.Per convention you must define the fetch routes as
public function fetchWhatever()
,fetchWhatever_dontcare
,fetchWhateverDontcare
; anyway, beeing it a valid function name it should be a valid url segment to use. No need to parse Str to other format thanStr::snake
, so we can get valid fetch routes and valid function names.Also it follow Laravel convention, when adding a field with namebilling_address
we know for sure it will get thefetchBillingAddress
orfetchBilling_address
.It get's it's urls from entity, that should match model entity and fetchEntity function.
Eg: