From: Marcel Werk Date: Sat, 14 Dec 2024 13:40:13 +0000 (+0100) Subject: Allow usage of a grid view as a form node X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ff7f2b15c4fa8e2fb064a945523559ccb30beb9b;p=GitHub%2FWoltLab%2FWCF.git Allow usage of a grid view as a form node --- diff --git a/wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php b/wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php new file mode 100644 index 0000000000..04f007b6d4 --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/GridViewFormNode.class.php @@ -0,0 +1,59 @@ + + * @since 6.2 + */ +class GridViewFormNode implements IFormChildNode +{ + use TFormChildNode; + use TFormNode; + + protected AbstractGridView $gridView; + + /** + * Returns the grid view object. + * + * @throws \BadMethodCallException if the grid view object has not been set yet + */ + public function getGridView(): AbstractGridView + { + if (!isset($this->gridView)) { + throw new \BadMethodCallException( + "Grid view object has not been set yet for node '{$this->getId()}'." + ); + } + + return $this->gridView; + } + + /** + * Sets the grid view object that contains the contents of the form node and returns this form node. + */ + public function gridView(AbstractGridView $gridView): static + { + $this->gridView = $gridView; + + return $this; + } + + #[\Override] + public function getHtml() + { + return $this->getGridView()->render(); + } + + #[\Override] + public function validate() + { + // does nothing + } +}