Hey all!
So yesterday I decided to upgrade my old kirby version to the most recent one. However, I ran into a problem. My custom panel field is not working anymore
I get this error (from which I concluded it can’t find/use my class):
Exception thrown with message “The parentimages field is missing. Please add it to your installed fields or remove it from your blueprint”
Somehow I am not suprised as the fields folder was already missing (which I manually added myself) when I downloaded the package. Is there some new way of doing custom fields or am I simply missing something?
Also here is my folder structure and field class:
_-- site
___-- fields
_____-- parentimages
_______-- parentimages.php
Parentimages.php:
class ParentimagesField extends BaseField {
public function __construct() {
$this->type = 'select';
$this->options = array();
$this->icon = 'chevron-down';
}
public function options() {
$array = array();
foreach ($this->page()->parent()->files() as $file) {
$array[$file->filename()] = $file->filename();
}
return $array;
}
public function option($value, $text, $selected = false) {
return new Brick('option', $this->i18n($text), array(
'value' => $value,
'selected' => $selected
));
}
public function input() {
$select = new Brick('select');
$select->addClass('selectbox');
$select->attr(array(
'name' => $this->name(),
'id' => $this->id(),
'required' => $this->required(),
'autocomplete' => $this->autocomplete(),
'autofocus' => $this->autofocus(),
'readonly' => $this->readonly(),
'disabled' => $this->disabled(),
));
$default = $this->default();
if(!$this->required()) {
$select->append($this->option('', '', $this->value() == ''));
}
if($this->readonly()) {
$select->attr('tabindex', '-1');
}
foreach($this->options() as $value => $text) {
$select->append($this->option($value, $text, $this->value() == $value));
}
$inner = new Brick('div');
$inner->addClass('selectbox-wrapper');
$inner->append($select);
$wrapper = new Brick('div');
$wrapper->addClass('input input-with-selectbox');
$wrapper->append($inner);
if($this->readonly()) {
$wrapper->addClass('input-is-readonly');
} else {
$wrapper->attr('data-focus', 'true');
}
return $wrapper;
}
public function validate() {
return array_key_exists($this->value(), $this->options());
}
}