Search code examples
yii2detailview

Yii2 two DetailView side by side


I'm making a purchase order system that exports the PO to PDF, but I need in the upper part to display data from buyer and also from seller. I would like to have 2 DetailViews side by side, each one with a 50% of page width. It is possible? So far I've not found any info regarding this and my CSS skills are low. Thanks for any info.


Solution

  • You can unse bootstrap grid In view you can palce the detailView in two separated bootstrap column

        <div class="col-sm-6 col-md-6 col-lg-6" >
    
        <?= DetailView::widget([
            'model' => $modelBuyer,
            ......
    
    
    
        ?>
       </div>
        <div class="col-sm-6 col-md-6 col-lg-6" >
    
        <?= DetailView::widget([
            'model' => $modelSeller,
            ......
    
    
    
        ?>
       </div>
    

    in controller simply pass the two models in render

           return $this->render('your_view', [
            'modelBuyer' => $modelBuyer,
            'modelSeller' => $modelSeller,
        ]);