diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 83c9899..9e6839f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -48,6 +48,7 @@ Yii Framework 2 Change Log - Bug #3681: Fixed problem with AR::findOne() when a default scope joins another table so that PK name becomes ambigous (cebe) - Bug #3715: Fixed the bug that using a custom pager/sorter with `GridView` may generate two different pagers/sorters if the layout configures two pagers/sorters (qiangxue) - Bug #3716: `DynamicModel::validateData()` does not call `validate()` if the `$rules` parameter is empty (qiangxue) +- Bug #3738: ActiveField custom error selector not functioning (qiangxue) - Bug #3751: Fixed postgreSQL schema data for enum values, do not add values if there are none (makroxyz) - Bug #3752: `QueryBuilder::batchInsert()` does not typecast input values (qiangxue) - Bug #3756: Fix number formatting error for `\yii\base\Formatter` by converting strings to float (kartik-v) diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index 35d9002..dd58294 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -126,7 +126,7 @@ class ActiveField extends Component * * You normally do not need to set this property as the default selectors should work well for most cases. */ - public $selectors; + public $selectors = []; /** * @var array different parts of the field (e.g. input, label). This will be used together with * [[template]] to generate the final field HTML code. The keys are the token names in [[template]], @@ -725,13 +725,17 @@ class ActiveField extends Component foreach (['validateOnChange', 'validateOnBlur', 'validateOnType', 'validationDelay'] as $name) { $options[$name] = $this->$name === null ? $this->form->$name : $this->$name; } + $options['container'] = isset($this->selectors['container']) ? $this->selectors['container'] : ".field-$inputID"; $options['input'] = isset($this->selectors['input']) ? $this->selectors['input'] : "#$inputID"; - if (isset($this->errorOptions['class'])) { + if (isset($this->selectors['error'])) { + $options['error'] = $this->selectors['error']; + } elseif (isset($this->errorOptions['class'])) { $options['error'] = '.' . implode('.', preg_split('/\s+/', $this->errorOptions['class'], -1, PREG_SPLIT_NO_EMPTY)); } else { $options['error'] = isset($this->errorOptions['tag']) ? $this->errorOptions['tag'] : 'span'; } + $options['encodeError'] = !isset($this->errorOptions['encode']) || $this->errorOptions['encode'] !== false; return $options;