public function WebformSubmissionNotesEditField::viewsForm in Webform Views Integration 8.5
Form constructor for the views form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- src/
Plugin/ views/ field/ WebformSubmissionNotesEditField.php, line 35
Class
- WebformSubmissionNotesEditField
- Webform submission notes field that allows to edit them.
Namespace
Drupal\webform_views\Plugin\views\fieldCode
public function viewsForm(&$form, FormStateInterface $form_state) {
// Make sure we do not accidentally cache this form.
$form['#cache']['max-age'] = 0;
// The view is empty, abort.
if (empty($this->view->result)) {
unset($form['actions']);
return;
}
$form[$this->options['id']]['#tree'] = TRUE;
foreach ($this->view->result as $row_index => $row) {
/** @var WebformSubmissionInterface $webform_submission */
$webform_submission = $this
->getEntity($row);
$form[$this->options['id']][$row_index] = [
'#type' => 'textarea',
'#default_value' => $webform_submission
->getNotes(),
];
}
}