I am creating a custom views field plugin, and I am having a huge amount of notices in the dblog that I cannot trace.
It's a simple views field plugin that just renders some content into a custom "non-db" field on the view.
Issue #1, is that in the view, the field is listed as just ':' (The field group and field name are not being displayed on the view).
Secondly, I am receiving these notices in the dblog Notice: Trying to access array offset on value of type null in Drupal\views\Plugin\views\HandlerBase->adminLabel() (line 159 of /home/jfurnas/sites/lms/docroot/core/modules/views/src/Plugin/views/HandlerBase.php)
These errors only appear if I am in the views UI to manage the view. If I view the view regularly, it does not put the errors in the dblog.
I am defining the field like so, in my my_module.views.inc file
function request_system_views_data() {
$data['lms_request']['request_system_quick_edit'] = [
'title' => t('Quick Edit Request'),
'help' => t('Quick edit request details'),
'group' => 'LMS Request',
'field' => [
'title' => 'Quick Edit Request',
'id' => 'request_system_quick_edit',
],
];
}
Where as 'lms_request' is the machine name of a custom entity in the system, and my fieldplug class is defined as below:
<?php
namespace Drupal\request_system\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Provides Quick Edit field handler.
*
* @ViewsField("request_system_quick_edit")
*
* @DCG
* The plugin needs to be assigned to a specific table column through
* hook_views_data() or hook_views_data_alter().
* For non-existent columns (i.e. computed fields) you need to override
* self::query() method.
*/
class QuickEdit extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function query() {
return [];
}
// /**
// * {@inheritdoc}
// */
public function defineOptions() {
return [];
}
// /**
// * {@inheritdoc}
// */
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$entity = $values->_entity;
$build['#cache'] = [
'max-age' => 0
];
$build['request_information'] = [
'#markup' => 'Request Information For Request # '. $entity->id(),
];
return $build;
}
}
I am unsure what the problem could be. I define other custom fields in the system similarly
and they don't cause the same issues.