I’ve updated a website from Kirby 2 to 3. There is one custom field used in de panel. I’m trying to get it to work in Kirby 3, without any luck.
I’ve read the documentation of custom fields in Kirby 3, but it’s way to complex for my experience level.
Can anybody help me out?
The custom field counts the amount ($optellen) of rows in the structured field (reservering) of the page.
Can this be done another way then writing a custom field?
The custom field in Kirby 2:
<?php
class countreservationsField extends InfoField
{
public function result() {
return null;
}
public function element() {
$element = parent::element();
$element->addClass('field-with-icon');
return $element;
}
public function input() {
$optellen = 0;
foreach($this->page()->reservering()->toStructure() as $temp):
$optellen = $optellen + $temp->amount()->int();
endforeach ;
return '<div class="text">' . $optellen . '</div>';
}
}