Update the readme to reflect the $dashboard_columns variable

This commit is contained in:
Kevin MacMartin 2018-01-11 18:56:37 -05:00
parent e0a55cd56a
commit 9c5deaf737

View file

@ -40,12 +40,7 @@ First add a function to generate the page:
'heading' => 'Contact Form Submissions', 'heading' => 'Contact Form Submissions',
'model' => 'contact', 'model' => 'contact',
'rows' => Contact::getContactSubmissions(), 'rows' => Contact::getContactSubmissions(),
'cols' => [ 'cols' => Contact::$dashboard_columns
[ 'Date', 'created_at' ],
[ 'Name', 'name' ],
[ 'Email', 'email' ],
[ 'Message', 'message' ]
]
]); ]);
} }
``` ```
@ -53,7 +48,16 @@ First add a function to generate the page:
* `heading`: The title that will appear for this page * `heading`: The title that will appear for this page
* `model`: The model that will be accessed on this page * `model`: The model that will be accessed on this page
* `rows`: A function returning an array containing the data to be shown on this page * `rows`: A function returning an array containing the data to be shown on this page
* `cols`: An array containing a set of arrays where the first element of each is the visible column name and the second is the column name in the array * `cols`: Expects a variable called `$dashboard_columns` in the respective model that contains an array:
```php
public static $dashboard_columns = [
[ 'Date', 'created_at' ],
[ 'Name', 'name' ],
[ 'Email', 'email' ],
[ 'Message', 'message' ]
];
```
### Adding an Editable Model to the Dashboard ### Adding an Editable Model to the Dashboard
@ -171,14 +175,7 @@ This function should be named the same as the one above except with `Edit` at th
'model' => 'news', 'model' => 'news',
'id' => $id, 'id' => $id,
'item' => $item, 'item' => $item,
'columns' => [ 'columns' => News::$dashboard_columns
[ 'name' => 'title', 'type' => 'text', 'label' => 'The Title' ],
[ 'name' => 'iframe', 'type' => 'text' ],
[ 'name' => 'halign', 'type' => 'select', 'options' => [ 'left', 'center', 'right' ] ],
[ 'name' => 'story', 'type' => 'mkd' ],
[ 'label' => 'Header Image', 'name' => 'headerimage', 'type' => 'image' ],
[ 'name' => 'order', 'type' => 'hidden' ]
]
]); ]);
} }
``` ```
@ -188,11 +185,22 @@ This function should be named the same as the one above except with `Edit` at th
* `id`: Always set this to `$id` * `id`: Always set this to `$id`
* `item`: Always set this to `$item` * `item`: Always set this to `$item`
* `help_text`: An optional value that will add a box containing help text above the form if set * `help_text`: An optional value that will add a box containing help text above the form if set
* `columns`: An array containing a set of arrays where: * `columns`: Expects a variable called `$dashboard_columns` in the respective model that contains an array:
* `name` is the name of the column to be edited * `name` is the name of the column to be edited
* `type` is the type of column (details below) * `type` is the type of column (details below)
* `label` is an optional value that overrides the visible column name * `label` is an optional value that overrides the visible column name
```php
public static $dashboard_columns = [
[ 'name' => 'title', 'type' => 'text', 'label' => 'The Title' ],
[ 'name' => 'iframe', 'type' => 'text' ],
[ 'name' => 'halign', 'type' => 'select', 'options' => [ 'left', 'center', 'right' ] ],
[ 'name' => 'story', 'type' => 'mkd' ],
[ 'label' => 'Header Image', 'name' => 'headerimage', 'type' => 'image' ],
[ 'name' => 'order', 'type' => 'hidden' ]
];
```
###### Editable Column Types ###### Editable Column Types
The following is a list of possible `types` in the `columns` array for Editable Items: The following is a list of possible `types` in the `columns` array for Editable Items: