List columns now support specifying a default option used when the value would otherwise be null.
This commit is contained in:
parent
06ec662131
commit
c9a9c6ea16
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue