ux icon indicating copy to clipboard operation
ux copied to clipboard

[Livecomponent] Livecomponent breaks on integer overflow and stays broken

Open mmarton opened this issue 3 months ago • 1 comments

Hi all!

Example:

<?php

namespace App\Twig\Components;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent]
final class Test
{
    use DefaultActionTrait;

    #[LiveProp(writable: true)]
    public int $count = 0;
}
<div{{ attributes }}>
    <input type="text" data-model="count">
    {{ count|number_format }}
</div>

If you put a number larger than PHP_INT_MAX into the input field, then you get an Invalid checksum sent when updating the live component. Exception.

Thats ok, but it could be more precise. The problem is that if I delete, or change a smaller number below int_max, the error stays until I reload the page.

Image

Is there a way to prevent this?

mmarton avatar Oct 15 '25 07:10 mmarton

Hi!

In 2.28 we introduced https://symfony.com/bundles/ux-live-component/current/index.html#input-model-validation-modifiers, I think min_value() and max_value() could help you here!

Kocal avatar Oct 21 '25 07:10 Kocal