I have a drupal view that has a multiselect field at the top. Based on the grid row selection and multiselect field value, specific actions are carried out on the grid rows. It's all based out of VBO module. View looks like below:
The multiselect field is the list of node title of a specific content type named "level2". I grabbed the "level2" node title and created that multiselect with the below code:
// Query nodes
$storage = Drupal::getContainer()->get('entity_type.manager')->getStorage('node');
$nids = $storage->getQuery();
// Gather published Level2 nodes and sort by title
$nids = $nids->condition('type', 'level2')
->condition('status', 1)
->sort('level2_title')
->execute();
// If there are no nodes, move on
if (!$nids) {
return FALSE;
}
// Start building out the options for our select list
$options = [];
$nodes = $storage->loadMultiple($nids);
// Push titles into select list
foreach ($nodes as $node) {
$options[$node->id()] = $node->getTitle();
}
$form['exposed_input']['ka_types'] = [
'#type' => 'select',
'#options' => $options,
'#multiple' => TRUE,
'#title' => 'Publish to Key Activities :',
];
array_unshift($form['#submit'], 'mymod_form_submit');
}
When performing a specific activity with the multiselect field, on the action file i read the value of the multiselect as:
$ka_selected = \Drupal::state()->get('ka_types');
However, I am unable to read the same field from the grid. doing dpm($entity) and dpm($node) does not show this field at all in the grid. Any help on how to read this field value from the view grid?