File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -109,18 +109,24 @@ public static function processAjaxSubmitError($options = []) {
109
109
*
110
110
* @param winternet\yii2\Result|null : Result instance, or provide null to have the method create an instance for you
111
111
* @param yii\base\model $model : A Yii model
112
+ * @param array $options : Available options:
113
+ * - `forActiveForm` : set true to use attribute names as needed by ActiveForm
112
114
*
113
115
* @return winternet\yii2\Result
114
116
*/
115
- public static function addModelResult ($ result , &$ model ) {
117
+ public static function addModelResult ($ result , &$ model, $ options = [] ) {
116
118
if (!$ result ) {
117
119
$ result = new \winternet \yii2 \Result ();
118
120
}
119
121
120
122
// Add errors
121
123
foreach ($ model ->getErrors () as $ attribute => $ errors ) {
122
- // Generate the form field ID so Yii ActiveForm client-side can apply the error message
123
- $ attributeId = \yii \helpers \Html::getInputId ($ model , $ attribute );
124
+ if (!empty ($ options ['forActiveForm ' ])) {
125
+ // Generate the form field ID so Yii ActiveForm client-side can apply the error message
126
+ $ attributeId = \yii \helpers \Html::getInputId ($ model , $ attribute );
127
+ } else {
128
+ $ attributeId = $ attribute ;
129
+ }
124
130
125
131
$ result ->addNamedErrors ($ attributeId , $ errors );
126
132
}
You can’t perform that action at this time.
0 commit comments