-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select DependsOn: Set Value Not Emitting Change #6380
Comments
Don't do the following. $request_data = request()->all();
$postal_info = null;
if (@$request_data['zip']) {
$zip = str_pad($request_data['zip'], 6, '0', STR_PAD_LEFT);
$postal_info = PostalInfo::where('zip', $zip)->first();
} Only depends on value available via |
@crynobone I got your point but. With that getting same issue on update page. The issue is happening with select field only on the update page! On create page it works without any issue! |
Again, this is not a supported behaviour. |
@crynobone I converted the code that is mentioned in the doc. I am seeing as bug that when you set value on the select field on the edit page of resource it's not working properly. return [
Text::make(__('Email'), 'email'),
PhoneNumber::make('Phone', 'phone')->format('###-###-####')->disableValidation()->nullable()
,
PhoneNumber::make('Fax', 'fax')->format('###-###-####')->disableValidation()->nullable(),
Text::make(__('Address Line 1'), 'address_1'),
Text::make(__('Address Line 2'), 'address_2'),
Text::make(__('Zip'), 'zip'),
Text::make(__('City'), 'city')->dependsOn(
'zip',
function ($field, $request, $formData) {
if (@$formData['zip']) {
$zip = str_pad($formData['zip'], 6, '0', STR_PAD_LEFT);
$postal_info = PostalInfo::where('zip', $zip)->first();
if (@$postal_info) {
$field->setValue($postal_info->city);
}
}
}
),
Select::make(__('State'), 'state')->options(config('states'))->searchable()->hideFromIndex()->hideFromDetail()->nullable()->displayUsingLabels()->dependsOn(
['zip'],
function (Select $field, NovaRequest $request, FormData $formData) {
if (@$formData['zip']) {
$zip = str_pad($formData['zip'], 6, '0', STR_PAD_LEFT);
$postal_info = PostalInfo::where('zip', $zip)->first();
if (@$postal_info) {
$field->setValue($postal_info->state);
}
}
}
),
Select::make(__('County'), 'county_id')->options($counties_arr)->searchable()->nullable()->hideFromDetail()->dependsOn(
'zip',
function (Select $field, NovaRequest $request, FormData $formData) {
if (@$formData['zip']) {
$zip = str_pad($formData['zip'], 6, '0', STR_PAD_LEFT);
$postal_info = PostalInfo::where('zip', $zip)->first();
if (@$postal_info) {
$field->setValue($postal_info->county_id);
}
}
}
),
]; |
Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example) |
@crynobone please use this repo: https://github.com/3owlcristian/nova-dependson-issue I have added some seeders also for testing postal codes. Issue happing on Contac Information resource update page! |
Confirmed this is a bug but going to reserve this for a major release to avoid breaking existing application. |
@crynobone thank you for your response! Hope v5 will released soon! |
@crynobone Why is this considered a breaking change if that is the expected behavior of the field?
|
Changing behaviour on existing application is a breaking change. Would you be happy if a paid product out of nowhere cause your application to break to fix an expectation by someone else? |
I understand breaking changes. Just imagine that I have a production application running without knowing that a certain method isn't working as expected. When I was implementing a part of my application, I noticed it immediately. What would happen in the scenario that I didn't? The customer would had noticed it. I would be happy if the change is mentioned in the release notes. |
@crynobone what about other paying customers who expect a feature to just work as it should? I am also curious as to why fixing a feature that is not working would break someone's application. When might this be fixed? Thanks! |
+1 We use |
Hello here, It seems the value is still updated when submitting the form and the issue is only on the UI feedback. Hope that helps! Bests |
This comment has been minimized.
This comment has been minimized.
@ozanhazer submit a proper bug report with reproducing code/repository. |
Hi @crynobone. Still looking forward to this fix. When could it be released? Thanks! |
This issue keeps biting. Still patiently waiting for the fix. |
Released with Laravel Nova 5.0.0 Feel free to open up a new issue if you're still experiencing this problem on the latest version. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
I'm using a feature called 'dependOn' to automatically fill in the city, county, and state fields based on the postal code entered. The state and county fields are select fields with predefined options.
The functionality works correctly for text fields, but I'm experiencing issues with the select fields. Initially, when the select field has no value and I change the postal code, the correct value is selected based on the new postal code. However, after this initial selection, the value in the select field does not change anymore, even though I can see in the request that the value is correctly set for the field.
This issue only occurs on the update page. On the create page, the functionality works without any issues. I am also attaching video of this issue. https://www.awesomescreenshot.com/video/27543474?key=e26c0283592351a50ea820d7a7f4b33b
The text was updated successfully, but these errors were encountered: