Very long time and no post – but I need to give a shoutout how this framework (still) kicks some serious ass
So… I haven’t been working properly with Kirby in months or even years. But today I wanted to create an intelligent snippet for select
fields. And just some simple thought like “Well, if I’d do this then this should do that…” led to a great result. Without browsing through the forum etc. Damn, I love how easy this framework language works
What I wanted to do was making it super flexible to create a select
field via a snippet’s array. And it “just” worked
<?php snippet('forms/fields/select', ['label' => 'Kursauswahl', 'size' => 0, 'options' => 'Kann; man; machen; muß aber nicht']) ?>
<div class="field">
<label for="<?= Str::slug($label) ?>"><?= $label ?></label>
<select id="<?= Str::slug($label) ?>" name="<?= Str::slug($label) ?>" size="<?= $size ?>">
<?php $option = Str::split($options, ';'); foreach ($option as $o): ?>
<option value="<?= Str::slug($o) ?>"><?= $o ?></option>
<?php endforeach ?>
</select>
</div>
No big news at all, nothing special – but just a super satisfying experience for someone who doesn’t work as often with Kirby as he would like to