display index using bootstrap collapse widget

I’ve tried displaying my Faq entries using kartik’s gridview and expand column but I couldn’t get the expanded row’s data to wrap so I’m trying to use the collapse widget to display faq answers to the questions when clicked on. What am I doing wrong here?

I get error:

exception ‘yii\base\InvalidConfigException’ with message ‘The ‘label’ option is required.’ in /home/drcarr/public_html/vendor/yiisoft/yii2-bootstrap/Collapse.php:107

Stack trace:

#0 /home/drcarr/public_html/vendor/yiisoft/yii2-bootstrap/Collapse.php(91): yii\bootstrap\Collapse->renderItems()

#1 /home/drcarr/public_html/vendor/yiisoft/yii2/base/Widget.php(102): yii\bootstrap\Collapse->run()

#2 /home/drcarr/public_html/frontend/views/faq/index.php(25): yii\base\Widget::widget(Array)

#3 /home/drcarr/public_html/vendor/yiisoft/yii2/base/View.php(326): require(’/home/drcarr/pu…’)

#4 /home/drcarr/public_html/vendor/yiisoft/yii2/base/View.php(248): yii\base\View->renderPhpFile(’/home/drcarr/pu…’, Array)

#5 /home/drcarr/public_html/vendor/yiisoft/yii2/base/View.php(150): yii\base\View->renderFile(’/home/drcarr/pu…’, Array, Object(frontend\controllers\FaqController))

#6 /home/drcarr/public_html/vendor/yiisoft/yii2/base/Controller.php(378): yii\base\View->render(‘index’, Array, Object(frontend\controllers\FaqController))

#7 /home/drcarr/public_html/frontend/controllers/FaqController.php(44): yii\base\Controller->render(‘index’, Array)

#8 [internal function]: frontend\controllers\FaqController->actionIndex()

#9 /home/drcarr/public_html/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)

#10 /home/drcarr/public_html/vendor/yiisoft/yii2/base/Controller.php(154): yii\base\InlineAction->runWithParams(Array)

#11 /home/drcarr/public_html/vendor/yiisoft/yii2/base/Module.php(454): yii\base\Controller->runAction(‘index’, Array)

#12 /home/drcarr/public_html/vendor/yiisoft/yii2/web/Application.php(100): yii\base\Module->runAction(‘faq/index’, Array)

#13 /home/drcarr/public_html/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))

#14 /home/drcarr/public_html/frontend/web/index.php(18): yii\base\Application->run()

#15 {main}

index.php




$faqs = [];


foreach ($dataProvider as $faq => $faqs[]) {

    $faqs[] = [

        'label' => $model->faq_question,

        'content' => $model->faq_answer,

    ];

}

?>


<div class="site-about">

    <h1><?= Html::encode($this->title) ?></h1>

    

   <?= Collapse::widget(['items'=> $faqs]);

    ?>


</div>






controller:




public function actionIndex()

    {

        $searchModel = new FaqSearch();

        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        

        return $this->render('index', [

            'searchModel' => $searchModel,

            'dataProvider' => $dataProvider,

        ]);

    }



I also tried adding an array to the model, but am not really sure if/how to use it in this instance:




public function getFaqs()

    {

        return ArrayHelper::map(Faq::find->all(),'id','faq_question','faq_answer');

    }