2014-03-19 96 views
0

這是我的陣列打印領域爲每種語言Yii的結合yiistrap和語言陣列

<?php foreach (Yii::app()->params['translatedLanguages'] as $l => $lang) : 
       if($l === Yii::app()->params['defaultLanguage']) $suffix = ''; 
       else $suffix = '_'.$l; 
       ?> 
       <fieldset> 
        <legend><?php echo $lang; ?></legend> 

        <div class="row"> 
         <?php echo $form->labelEx($model,'title'); ?> 
         <?php echo $form->textField($model,'title'.$suffix,array('size'=>60,'maxlength'=>255)); ?> 
         <?php echo $form->error($model,'title'.$suffix); ?> 
        </div> 

        <div class="row"> 
         <?php echo $form->labelEx($model,'content'); ?> 
         <?php echo $form->textArea($model,'content'.$suffix); ?> 
         <?php echo $form->error($model,'content'.$suffix); ?> 
        </div> 
       </fieldset> 
      <?php endforeach; ?> 

這是對標籤
http://www.getyiistrap.com/site/widgets#tabs

<?php $this->widget('bootstrap.widgets.TbTabs', array(
       'placement' => 'below', 
       'tabs' => array(
        array('label' => 'Home', 'content' => 'home test', 'active' => true), 
        array('label' => 'Profile', 'content' => 'profile test.'), 
       ), 
      )); ?> 

我怎能取代的yiistrap碼內容(例如家庭測試)與我的表單中的字段? 所以,最後我有一個選項卡爲每種語言(如Opencart的)

回答

0

這是在我看來

<?php $tabs = array(); ?> 
    <?php foreach (Yii::app()->params['translatedLanguages'] as $l => $lang) : 
     if($l === Yii::app()->params['defaultLanguage']) $suffix = ''; 
     else $suffix = '_'.$l; 
     ?> 
     <?php $tabs[] = array('label' => $lang, 'view' => '_fields', 'viewData' => array('form' => $form, 'model' => $model, 'suffix' => $suffix)); ?> 
    <?php endforeach; ?> 

    <?php $this->widget('bootstrap.widgets.TbTabs', array(
     'tabs' => $tabs, 
     'viewData' => array('form' => $form, 'model' => $model, 'suffix' => $suffix), 
    )); ?> 

選項卡上的代碼,我添加了另一個觀點_fields.php

<?php echo $form->textFieldControlGroup($model,'title'.$suffix,array('span'=>5,'maxlength'=>128)); ?> 
<?php echo $form->textAreaControlGroup($model,'content'.$suffix,array('rows'=>6,'span'=>8)); ?> 

我在TbTabs.php改變了這個($ tabOptions [ '可視數據'])

protected function normalizeTabs($tabs) 
{ 
    $controller = $this->getController(); 
    if (isset($controller)) { 
     foreach ($tabs as &$tabOptions) { 
      $items = TbArray::getValue('items', $tabOptions, array()); 
      if (!empty($items)) { 
       $tabOptions['items'] = $this->normalizeTabs($items); 
      } else { 
       if (isset($tabOptions['view'])) { 
        $view = TbArray::popValue('view', $tabOptions); 
        if ($controller->getViewFile($view) !== false) { 
         $tabOptions['content'] = $controller->renderPartial($view, $tabOptions['viewData'], true); 
        } 
       } 
      } 
     } 
    } 
    return $tabs; 
} 
+0

我如何可以覆蓋TbTabs.php?我現在只是黑客,這不好 – Ruben