X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fentity_browser%2Fsrc%2FPlugin%2Fviews%2Ffield%2FSelectForm.php;fp=web%2Fmodules%2Fcontrib%2Fentity_browser%2Fsrc%2FPlugin%2Fviews%2Ffield%2FSelectForm.php;h=d498082b89d670e2a871be40e098a9a608d0454c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/entity_browser/src/Plugin/views/field/SelectForm.php b/web/modules/contrib/entity_browser/src/Plugin/views/field/SelectForm.php new file mode 100644 index 000000000..d498082b8 --- /dev/null +++ b/web/modules/contrib/entity_browser/src/Plugin/views/field/SelectForm.php @@ -0,0 +1,93 @@ +getEntity($row); + return $entity->getEntityTypeId() . ':' . $entity->id(); + } + + /** + * {@inheritdoc} + */ + public function render(ResultRow $values) { + return ViewsRenderPipelineMarkup::create(''); + } + + /** + * {@inheritdoc} + */ + public function preRender(&$values) { + parent::preRender($values); + + // If the view is using a table style, provide a placeholder for a + // "select all" checkbox. + if (!empty($this->view->style_plugin) && $this->view->style_plugin instanceof Table) { + // Add the tableselect css classes. + $this->options['element_label_class'] .= 'select-all'; + // Hide the actual label of the field on the table header. + $this->options['label'] = ''; + } + } + + /** + * Form constructor for the bulk form. + * + * @param array $render + * An associative array containing the structure of the form. + */ + public function viewsForm(&$render) { + // Only add the bulk form options and buttons if there are results. + if (!empty($this->view->result)) { + // Render checkboxes for all rows. + $render[$this->options['id']]['#tree'] = TRUE; + $render[$this->options['id']]['#printed'] = TRUE; + foreach ($this->view->result as $row) { + $value = $this->getRowId($row); + + $render[$this->options['id']][$value] = [ + '#type' => 'checkbox', + '#title' => $this->t('Select this item'), + '#title_display' => 'invisible', + '#return_value' => $value, + '#attributes' => ['name' => "entity_browser_select[$value]"], + '#default_value' => NULL, + ]; + } + } + } + + /** + * {@inheritdoc} + */ + public function query() {} + + /** + * {@inheritdoc} + */ + public function clickSortable() { + return FALSE; + } + +}