framework/base/Model.php
public static function loadMultiple($models, $data, $formName = null)
    {
        if ($formName === null) {
            /* @var $first Model|false */
            $first = reset($models);
            if ($first === false) {
                return false;
            }
            $formName = $first->formName();
        }

        $success = false;
        foreach ($models as $i => $model) {
            /* @var $model Model */
            if ($formName == '') {
                if (!empty($data[$i]) && $model->load($data[$i], '')) {
                    $success = true;
                }
            } elseif (!empty($data[$formName][$i]) && $model->load($data[$formName][$i], '')) {
                $success = true;
            }
        }

        return $success;
    }
public static function loadMultiple($models, $data, $formName = null)
    {
        if ($formName === null) {
            /* @var $first Model|false */
            $first = reset($models);
            if ($first === false) {
                return false;
            }
            $formName = $first->formName();
        }

        $success = false;
        foreach ($models as $i => $model) {
            /* @var $model Model */
            if ($formName == '') {
                if (!empty($data[$i]) && $model->load($data[$i], '')) {
                    $success = true;
                }
            } elseif (!empty($data[$formName][$i]) && $model->load($data[$formName][$i], '')) {
                $success = true;
            }
        }

        return $success;
    }
public static function loadMultiple ( $ models , $ data , $ formName = null ) { if ( $ formName === null ) { /* @var $first Model|false */ $ first = reset ( $ models ) ; if ( $ first === false ) { return false ; } $ formName = $ first -> formName ( ) ; } $ success = false ; foreach ( $ models as $ i => $ model ) { /* @var $model Model */ if ( $ formName == '' ) { if ( ! empty ( $ data [ $ i ] ) && $ model -> load ( $ data [ $ i ] , '' ) ) { $ success = true ; } } elseif ( ! empty ( $ data [ $ formName ] [ $ i ] ) && $ model -> load ( $ data [ $ formName ] [ $ i ] , '' ) ) { $ success = true ; } } return $ success ; }
Populates a set of models with the data from end user.
This method is mainly used to collect tabular data input.
The data to be loaded for each model is `$data[formName][index]`, where `formName`
refers to the value of [[formName()]], and `index` the index of the model in the `$models` array.
If [[formName()]] is empty, `$data[index]` will be used to populate each model.
The data being populated to each model is subject to the safety check by [[setAttributes()]].
@param array $models the models to be populated. Note that all models should have the same class.
@param array $data the data array. This is usually `$_POST` or `$_GET`, but can also be any valid array
supplied by end user.
@param string $formName the form name to be used for loading the data into the models.
If not set, it will use the [[formName()]] value of the first model in `$models`.
This parameter is available since version 2.0.1.
@return bool whether at least one of the models is successfully populated.
Populates a set of models with the data from end user . This method is mainly used to collect tabular data input . The data to be loaded for each model is $data [ formName ] [ index ] where formName refers to the value of [[ formName () ]] and index the index of the model in the $models array . If [[ formName () ]] is empty $data [ index ] will be used to populate each model . The data being populated to each model is subject to the safety check by [[ setAttributes () ]] .