所以我创建了一个类,例如:
class CoreTheme_Form_Helpers_TabbedForm extends AisisCore_Form_Helpers_Content{
protected $_html = '';
public function init(){
parent::init();
if(isset($this->_options)){
$this->_html .= '<ul class="nav nav-tabs">';
foreach($this->_options as $options){
$this->_html .= '<li><a href="#'.str_replace(" ", "", $options['tab']).'" data-toggle="tab">
'.$options['tab'].'</a></li>';
}
$this->_html .= '</ul>';
$this->_html .= '<div class="tab-content">';
foreach($this->_options as $options){
$this->_html .= '<div class="tab-pane" id="'.str_replace(" ", "", $options['tab']).'">...</div>';
}
$this->_html .= '</div>';
}
}
public function __toString(){
return $this->_html;
}
}
我要做的是使用类选项卡窗格将活动类添加到 div 中,但只添加一次,并且只添加到第一个。
所以在:
foreach($this->_options as $options){
$this->_html .= '<div class="tab-pane" id="'.str_replace(" ", "", $options['tab']).'">...</div>';
}
html应该是这样的:
<div class="tab-pane active" id="something">...</div>
<div class="tab-pane" id="something1">...</div>
<div class="tab-pane" id="something2">...</div>
想法?