From 578441786287d1c1860cd465843d7ffa6efd12b7 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 28 Feb 2015 11:50:27 +1100 Subject: [PATCH] Document widget accepted config These definitions don't serve a function other than helping developers --- modules/backend/classes/WidgetBase.php | 4 ++-- modules/backend/widgets/Form.php | 17 ++++++++++++++ modules/backend/widgets/Lists.php | 31 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/modules/backend/classes/WidgetBase.php b/modules/backend/classes/WidgetBase.php index 1ff986cc4..4e64d9a8a 100644 --- a/modules/backend/classes/WidgetBase.php +++ b/modules/backend/classes/WidgetBase.php @@ -13,14 +13,14 @@ use Session; */ abstract class WidgetBase { + use \System\Traits\ViewMaker; use \System\Traits\AssetMaker; use \System\Traits\ConfigMaker; - use \System\Traits\ViewMaker; use \Backend\Traits\WidgetMaker; use \October\Rain\Support\Traits\Emitter; /** - * @var array Supplied configuration. + * @var object Supplied configuration. */ public $config; diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 14a720ba2..613c25e55 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -23,6 +23,23 @@ use October\Rain\Database\Model; */ class Form extends WidgetBase { + /** + * @var array Expected configuration: + * + * - fields: outside form field definitions + * - tabs: primary tab form field definitions + * - secondaryTabs: secondary tab form field definitions + * - arrayName: a HTML array name to use for each element + * - context: apply a context to this form and its fields + */ + public $config = [ + 'fields' => [], + 'tabs' => [], + 'secondaryTabs' => [], + 'arrayName' => null, + 'context' => null, + ]; + /** * {@inheritDoc} */ diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index 308629924..24820564a 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -25,6 +25,37 @@ use DateTime; */ class Lists extends WidgetBase { + /** + * @var array Expected configuration: + * + * - columns: list column definitions + * - model: object or class name, data is loaded from this model + * - recordUrl: link each list record to another page + * - recordOnClick: custom JavaScript code to execute when clicking on a record + * - noRecordsMessage: a message to display when no records are found + * - recordsPerPage: records to display per page, use 0 for no pages + * - showSorting: displays the sorting link on each column + * - defaultSort: sets a default sorting column and direction + * - showCheckboxes: displays checkboxes next to each record + * - showSetup: displays the list column set up button + * - showTree: displays a tree hierarchy for parent/child records + * - treeExpanded: if tree nodes should be expanded by default + */ + public $config = [ + 'model' => null, + 'columns' => [], + 'recordUrl' => null, + 'recordOnClick' => null, + 'noRecordsMessage' => null, + 'recordsPerPage' => 0, + 'showSorting' => true, + 'defaultSort' => ['column' => null, 'direction' => null], + 'showCheckboxes' => false, + 'showSetup' => false, + 'showTree' => false, + 'treeExpanded' => false, + ]; + /** * {@inheritDoc} */