09E3 substituted with 9000 (when reading from a textfile)

Hi

I am reading a text-file.

- 
  klasse: 05D3
- 
  klasse: 05E3
- 
  klasse: 05F3

These string end up in a combobox:

grafik

As you can see, the 05E3 is displayed as 5000. Same for 06E3 → 6000.

The reason is obvious (5 * 10^3 = 5000). But I have no clue whatsoever how to prevent this math-“feature”…
The demo of this issue is here: Krankmeldung von Schülern | KGS Rastede

<select type="form-select" id="klasse" class="form-select" name="klasse" value="<?= $data['klasse'] ?? '' ?>" required>

                                <option selected disabled>Klasse auswählen</option>

                                <?php foreach (page('formulare/klassen')->klassen()->toStructure() as $klasse) : //Das Kirby Feld durchlaufen für alle Einträge ?>
                                <?php if ($klasse->klasse() == '------') : //Die Striche sollen nur als Trennung dienen ?>
                                    <option disabled class='text-muted'><?= $klasse->klasse() ?></option>
                                <?php else : ?>
                                    <option><?= $klasse->klasse() ?></option>
                                <?php endif ?>

                                <?php endforeach ?>
                            </select>

Thanks in advance :slight_smile:

Try

<option><?= $klasse->klasse()->value() ?></option>

or

<option><?= $klasse->klasse()->toString() ?></option>

In fact, both don’t work. No effect at all.

I “solved” it be adding a space in between the 05 and the E3 (05 E3 instead of 05E3), but that is not the correct name so quite a ugly workaround.

Did you add those values manually or via the Panel? In my test with a text field they are saved with quotes:

Klasse:

- 
  klasse: "05E3"
- 
  klasse: "09E3"

And the output is then correct. So the solution would be to wrap your input in quotes.

Indeed, that was the issues… First of all, thank you for the pointer!

I’d like to understand it… I guess the “06E3” - internally - leads to an explicit casting to a String while the string 06E3 without the " is implicitly casted to 6000? This might be a cornercase for the documentation, perhaps?

Yes, Parsedown (the Markdown parser used by Kirby) obviously treats this value as a number if it isn’t explicitly marked as a string. The convertion happens when you call toStructure() or toYaml() on the structure field.