Dec 1, 2021
0
Level 5
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.
Please or to participate in this conversation.