Hi,
im having problems with the following function:
public function filterFields($fields, $context = null)
{
if (!$backendUser = BackendAuth::getUser())
throw new \Exception('No admin logged in');
$authorChangeAllowed = $backendUser->hasPermission('vendor.plugin.manage_all_news');
// dd($fields->author);
if ($authorChangeAllowed) {
$fields->author->hidden = false;
} else {
$fields->author->hidden = true;
}
}
As described in the docs, the function allows for additional form field filtering. What I'm doing is quite obvious, restricting a single field (author - type: relation) from being visible by setting the hidden property of the field. For some reason I get the following PHP warning/error Creating default object from empty value. What's wrong with the code?
Regards Jakob
Last updated