-
Notifications
You must be signed in to change notification settings - Fork 903
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
select2_json_from_api behaviour when form is reloaded #5557
Comments
Hello @miquelangeld Can you rephrase? I'm unable to get the problem. Can you also share the CRUD code so we can know more about the issue? |
Hi @karandatwani92 summing up using a select2_json_from_api field, when you select a value and save, the stored value is something like this: {"id":"MURR230044149-1","booking":"MURR230044149-1 Localizador: MUR0002615"} But if the page reloads after you have selected an option (for example by saving the form without having filled in a required field causing a reload), and then save the form, then the same select2_json_from_api store in DB [{"id":"MURR230044149-1","booking":"MURR230044149-1 Localizador: MUR0002615"}] adding this square brackets $this->crud->addField([ I hope I have explained myself better this time :) |
ping @karandatwani92 |
Hey @miquelangeld sorry for the time it took to solve this issue. It seems it felt through the cracks 😢 I've now released backpack/pro 2.2.29 with the fix for the inconsistent behavior. Thank you very much for the time spent raising and explaining how to reproduce the issue 🙏 Let us know if you experience some other issues and we hopefully can fix them faster 😃 Cheers |
@pxpm there is and error with this change. I was facing the same issue i debuged and found the select is empty(on edit or saving the form without having filled in a required field) because is calling a undeclared variable. Actual code: @if ($value)
@if (is_object($value))
<option value="{{ json_encode($value) }}" selected>
{{ $item->{$field['attribute']} ?? '' }}
</option>
@else
@foreach ($value as $item)
@php
$item = is_string($item) ? json_decode($item) : (object) $item;
@endphp
<option value="{{ json_encode($item) }}" selected>
{{ $item->{$field['attribute']} ?? '' }}
</option>
@endforeach
@endif
@endif The variable @if (is_object($value))
<option value="{{ json_encode($value) }}" selected>
{{ $value->{$field['attribute']} ?? '' }}
</option>
@else
... |
Hi, I'm using select2_json_from_api, here is my code
In the same page I have another select2_json_from_api field but with include_all_form_fields = true
The text was updated successfully, but these errors were encountered: