Save multiple data

I’m newbie. I want to ask about how to save multiple data from multiple row like that this picture? I’m only can save one data from bottom row. Please help me

This is actionCreate in my controller

public function actionCreate() {

    $model = new TbSnSpare('id_spare');


    $model2 = new TbSpare;


    if (isset($_POST['TbSnSpare'])) {


        $model->attributes = $_POST['TbSnSpare'];


            if (isset($_POST['serial_number'])) {


                $total = count($_POST['serial_number']);


            for ($i = 0; $i <= $total; $i++) {


                       if (isset($_POST['serial_number'][$i])) {


                        $model->serial_number = $_POST['serial_number'][$i];


                        $model->save();                                     


                }


                }


                $this->redirect(array('view', 'id' => $model->id_sn));


            }


         }


     $this->render('create', array(


      'model' => $model,


      'dataProvider'=>$dataProvider,


 


     ));


     


}