Commit d5077d70 by Qiang Xue

Fixes #3738: ActiveField custom error selector not functioning

parent 4ad022c3
...@@ -48,6 +48,7 @@ Yii Framework 2 Change Log ...@@ -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 #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 #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 #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 #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 #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) - Bug #3756: Fix number formatting error for `\yii\base\Formatter` by converting strings to float (kartik-v)
......
...@@ -126,7 +126,7 @@ class ActiveField extends Component ...@@ -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. * 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 * @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]], * [[template]] to generate the final field HTML code. The keys are the token names in [[template]],
...@@ -725,13 +725,17 @@ class ActiveField extends Component ...@@ -725,13 +725,17 @@ class ActiveField extends Component
foreach (['validateOnChange', 'validateOnBlur', 'validateOnType', 'validationDelay'] as $name) { foreach (['validateOnChange', 'validateOnBlur', 'validateOnType', 'validationDelay'] as $name) {
$options[$name] = $this->$name === null ? $this->form->$name : $this->$name; $options[$name] = $this->$name === null ? $this->form->$name : $this->$name;
} }
$options['container'] = isset($this->selectors['container']) ? $this->selectors['container'] : ".field-$inputID"; $options['container'] = isset($this->selectors['container']) ? $this->selectors['container'] : ".field-$inputID";
$options['input'] = isset($this->selectors['input']) ? $this->selectors['input'] : "#$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)); $options['error'] = '.' . implode('.', preg_split('/\s+/', $this->errorOptions['class'], -1, PREG_SPLIT_NO_EMPTY));
} else { } else {
$options['error'] = isset($this->errorOptions['tag']) ? $this->errorOptions['tag'] : 'span'; $options['error'] = isset($this->errorOptions['tag']) ? $this->errorOptions['tag'] : 'span';
} }
$options['encodeError'] = !isset($this->errorOptions['encode']) || $this->errorOptions['encode'] !== false; $options['encodeError'] = !isset($this->errorOptions['encode']) || $this->errorOptions['encode'] !== false;
return $options; return $options;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment