diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index a3c9ee025..7bc8bf0e8 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -13,8 +13,8 @@ use System\Classes\SystemException; * type: recordfinder * list: @/plugins/rainlab/user/models/user/columns.yaml * prompt: Click the Find button to find a user - * nameColumn: name - * descriptionColumn: email + * nameFrom: name + * descriptionFrom: email * * @package october\backend * @author Alexey Bobkov, Samuel Georges @@ -49,12 +49,12 @@ class RecordFinder extends FormWidgetBase /** * @var string Relation column to display for the name */ - public $nameColumn; + public $nameFrom; /** * @var string Relation column to display for the description */ - public $descriptionColumn; + public $descriptionFrom; /** * @var string Prompt to display if no record is selected. @@ -81,8 +81,11 @@ class RecordFinder extends FormWidgetBase $this->prompt = $this->getConfig('prompt', 'Click the %s button to find a record'); $this->keyField = $this->getConfig('keyField', $this->keyField); - $this->nameColumn = $this->getConfig('nameColumn', $this->nameColumn); - $this->descriptionColumn = $this->getConfig('descriptionColumn', $this->descriptionColumn); + $this->nameFrom = $this->getConfig('nameFrom', $this->nameFrom); + $this->descriptionFrom = $this->getConfig('descriptionFrom', $this->descriptionFrom); + + /* @todo Remove line if year >= 2015 */ if ($this->getConfig('nameColumn')) $this->nameFrom = $this->getConfig('nameColumn'); + /* @todo Remove line if year >= 2015 */ if ($this->getConfig('descriptionColumn')) $this->descriptionFrom = $this->getConfig('descriptionColumn'); if (!$this->model->hasRelation($this->relationName)) throw new SystemException(Lang::get('backend::lang.model.missing_relation', ['class'=>get_class($this->controller), 'relation'=>$this->relationName])); @@ -163,18 +166,18 @@ class RecordFinder extends FormWidgetBase public function getNameValue() { - if (!$this->relationModel || !$this->nameColumn) + if (!$this->relationModel || !$this->nameFrom) return null; - return $this->relationModel->{$this->nameColumn}; + return $this->relationModel->{$this->nameFrom}; } public function getDescriptionValue() { - if (!$this->relationModel || !$this->descriptionColumn) + if (!$this->relationModel || !$this->descriptionFrom) return null; - return $this->relationModel->{$this->descriptionColumn}; + return $this->relationModel->{$this->descriptionFrom}; } public function onFindRecord() diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index e1213dcf4..30ea0e4d5 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -707,7 +707,7 @@ class Form extends WidgetBase $columnDotted = implode('.', $columnParts); $columnValue = array_get($data, $columnDotted, 0); if ($field->type == 'number') { - $columnValue = !strlen(trim($columnValue)) ? NULL : (float) $columnValue; + $columnValue = !strlen(trim($columnValue)) ? null : (float) $columnValue; } array_set($data, $columnDotted, $columnValue); }