Apr 4, 2024
0
Level 1
Livewire array errors not being showed because of php echo lines html
Hi, I found that in an array of items, if one item has an error, it is not shown. This is the php code (gotten with Xdebug)
<td class="celda">
<?php xdebug_break(); ?>
<input type="number" class="form-control form-control-sm"
wire:model.live.debounce.250ms="lineas.<?php echo e($index); ?>.cantidad" />
<!--[if BLOCK]><![endif]--><?php $__errorArgs = ['lineas.<?php echo e($index); ?>.cantidad'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?><!--[if ENDBLOCK]><![endif]-->
The problem is that in
if ($__bag->has($__errorArgs[0])) :
$__bag is
lineas.0.cantidad:
array(1)
0:
"El campo lineas.0.cantidad debe ser mayor que 0."
And $__errorArgs[0] contains:
lineas.<?php echo e($index); ?>.cantidad"
However, this returns false instead of true, therefore, the error is never shown.
$__bag->has($__errorArgs[0])
false
Please or to participate in this conversation.