Commit b7cad9df by abrahamy Committed by Alexander Makarov

Fixes #4371: Active form client validation wasn't working in case of two models…

Fixes #4371: Active form client validation wasn't working in case of two models having same named fields When rendering multiple models in the same ActiveForm if any of the field names in the two models is the same then the corresponding attribute in the yiiActiveForm object in yiiActiveForm.js (ie $('form').data('yiiActiveForm').attributes) of the first rendered model is overwritten by the attribute of the last model causing the client-side validation for the overwritten field not to run at all. Example: given two models Car and Owner with attributes {make, age} and {name, age} then if the Car is rendered first its age attribute will not have any client validation.
parent ba606d06
......@@ -69,6 +69,7 @@ Yii Framework 2 Change Log
- Bug #4241: `yii\widgets\Pjax` was incorrectly setting container id (mitalcoi)
- Bug #4276: Added check for UPLOAD_ERR_NO_FILE in `yii\web\UploadedFile` and return null if no file was uploaded (OmgDef)
- Bug #4342: mssql (dblib) driver does not support getting attributes (tof06)
- Bug #4371: Active form client validation wasn't working in case of two models having same named fields (abrahamy)
- Bug #4409: Upper case letters in subdirectory prefixes of controller IDs were not properly handled (qiangxue)
- Bug #4412: Formatter used SI Prefixes for base 1024, now uses binary prefixes (kmindi)
- Bug #4427: Formatter could do one division too much (kmindi)
......
......@@ -195,7 +195,7 @@ class ActiveField extends Component
{
$clientOptions = $this->getClientOptions();
if (!empty($clientOptions)) {
$this->form->attributes[$this->attribute] = $clientOptions;
$this->form->attributes[Html::getInputId($this->model, $this->attribute)] = $clientOptions;
}
$inputID = Html::getInputId($this->model, $this->attribute);
......
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