List columns now support specifying a default option used when the value would otherwise be null.

This commit is contained in:
Samuel Georges 2015-06-27 10:39:07 +10:00
parent 06ec662131
commit c9a9c6ea16
3 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,6 @@
* **Build 27x** (2015-06-xx)
- List columns now support specifying a `default` option used when the value would otherwise be null.
* **Build 272** (2015-06-27)
- Protected images and their thumbnails are now supported in the back-end.
- Editing CMS templates now support form fields that use AJAX.

View File

@ -47,6 +47,11 @@ class ListColumn
*/
public $valueFrom;
/**
* @var string Specifies a default value when value is empty.
*/
public $defaults;
/**
* @var string Custom SQL for selecting this record display value,
* the @ symbol is replaced with the table name.
@ -134,6 +139,9 @@ class ListColumn
if (isset($config['valueFrom'])) {
$this->valueFrom = $config['valueFrom'];
}
if (isset($config['default'])) {
$this->defaults = $config['default'];
}
if (isset($config['select'])) {
$this->sqlSelect = $config['select'];
}

View File

@ -783,6 +783,13 @@ class Lists extends WidgetBase
$value = $this->{'eval'. studly_case($column->type) .'TypeValue'}($record, $column, $value);
}
/*
* Apply default value.
*/
if (empty($value)) {
$value = $column->defaults;
}
/*
* Extensibility
*/