Closed juanyrascon closed 1 year ago
@juanyrascon That's a really particular and strange situation. I don't believe it's related to this package or to AdminLTE
. The only difference between a create
and an edit
form is that in the edit
form the select2
input may already contain data. I suggest you to try to enclose the issue, for example:
select2
component in the edit form and check whether the issue persist:<select class="form-control select2" name="branches_id[]" id="branches_id" multiple>
{{--
@foreach ($branches as $branch)
<option value="{{ $branch->id }}" {{ in_array($branch->id, old('branches', [])) || $user->branches->contains($branch->id) ? 'selected' : '' }}> {{ $branch->name }} </option>
@endforeach
--}}
</select>
select2
component in the edit form and check whether the issue persist:
<select class="form-control select2" name="branches_id[]" id="branches_id" multiple>
<option value="1" selected>val1</option>
<option value="2" selected>val2</option>
<option value="3">val3</option>
<option value="4">val4</option>
</select>
If in those cases, you don't observe the issue, then the problem is related to how you fill the options
in the @foreach
loop (maybe data comes with hidden characters from the database, \t
or something like that). If the issue persist in those cases, you may try updating the plugin files to a newer version.
Finally, the problem was the vscode setting, "the length of line wrap size: 80", I changed it to "the length of line wrap size: 280".
@dfsmania Muchas gracias por tu ayuda.
I have a problem using select2 multiple in the edit page, when I press the backspace key, blank spaces are shown at the beginning (always show 49 spaces), in the photo it is better appreciated.
On the other hand, in the create page, it works normally, without blank spaces... that's how I want the edit page to work.
Edit view:
<select class="form-control select2" name="branches_id[]" id="branches_id" multiple> @foreach ($branches as $branch) <option value="{{ $branch->id }}" {{ in_array($branch->id, old('branches', [])) || $user->branches->contains($branch->id) ? 'selected' : '' }}> {{ $branch->name }} </option> @endforeach </select>
Controller
public function edit(User $user) { $branches = Branch::all(); return view('users.edit', compact('user', 'branches')); }
I already broke my head and I have not been able to solve it.
Any ideas to solve the issue. all help will be greatly appreciated and received.