Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

twoarmtom's avatar

Laravel Nova removes '0' in KeyValue pair

I'm having an issue I haven't noticed before. I use the KeyValue pair in Laravel Nova to save a rating scale. The setup is below:

public function fields(Request $request)
    {
        return [
            Text::make('Scale', 'form')->rules('required'),

            Text::make('Title')->rules('required'),

            Trix::make('Instructions'),

            KeyValue::make('Scores and Descriptions', 'score_description')
            ->keyLabel('Score')
            ->valueLabel('Description')
            ->rules('required'),
        ];
    }

If I use a scoring system that is all numbers like 0, 1, 2, 3 as the 'Score' in the KeyValue pair, it will save initially, but if I edit, the 0 score and description will be removed. However, if I add a string to the scoring, like N/A, the 0 is not removed upon editing.

So my question is: Is there a way to keep a 0 without having to add a string as a key?

Thanks for any help.

0 likes
0 replies

Please or to participate in this conversation.