core/traits/RestBehaviorsTrait.php
public function sendArrayError(array $errors)
    {
        Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
        $result = [];
        foreach ($errors as $key => $value) {
            $messages = (array) $value;
            
            foreach ($messages as $msg) {
                $result[] = ['field' => $key, 'message' => $msg];
            }
        }
        
        return $result;
    }
public function sendArrayError(array $errors)
    {
        Yii::$app->response->setStatusCode(422, 'Data Validation Failed.');
        $result = [];
        foreach ($errors as $key => $value) {
            $messages = (array) $value;
            
            foreach ($messages as $msg) {
                $result[] = ['field' => $key, 'message' => $msg];
            }
        }
        
        return $result;
    }
public function sendArrayError ( array $ errors ) { Yii :: $ app -> response -> setStatusCode ( 422 , 'Data Validation Failed.' ) ; $ result = [ ] ; foreach ( $ errors as $ key => $ value ) { $ messages = ( array ) $ value ; foreach ( $ messages as $ msg ) { $ result [ ] = [ 'field' => $ key , 'message' => $ msg ] ; } } return $ result ; }
Send Array validation error.

Example input:

```php
return $this->sendArrayError(['firstname' => 'Firstname cannot be blank']);
```

Example return value:

```php
Array
(
[0] => Array
(
[field] => firstname
[message] => Firstname cannot be blank.
)
)
```
@param array $errors Provide an array with messages. Where key is the field and value the message.
@return array Returns an array with field and message keys for each item.
@since 1.0.3
Send Array validation error .