public function run()
    {
        $model = $this->model;
        $cities = $this->cities;
        $locations = $model->locations;
        if (empty($locations)) {
            $location = new CompetitionLocation();
            $locations = array($location->attributes);
        }
        //tab
        echo CHtml::openTag('ul', array('class' => 'nav nav-tabs', 'role' => 'tablist'));
        foreach ($locations as $key => $location) {
            $index = $key + 1;
            echo CHtml::tag('li', array('class' => $key == 0 ? 'active' : ''), CHtml::tag('a', array('href' => '#location-' . $index, 'role' => 'tab', 'data-toggle' => 'tab'), '地址' . $index . ($key == 0 ? '<span class="required">*</span></a>' : '')));
        }
        echo '<li><a id="addLocation"><i class="fa fa-plus"></i> 添加</a></li>';
        echo CHtml::closeTag('ul');
        echo '<div class="text-danger col-lg-12">地址1必填,除非多地点比赛,否则请只填写一个地址,留空即可删去多余地址。</div>';
        //tab content
        echo CHtml::openTag('div', array('class' => 'tab-content locations'));
        foreach ($locations as $key => $location) {
            $index = $key + 1;
            echo CHtml::openTag('div', array('class' => 'tab-pane location' . ($key == 0 ? ' active' : ''), 'id' => 'location-' . $index));
            echo Html::formGroup($model, 'locations[province_id][]', array('class' => 'col-lg-6'), CHtml::label('省份', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[province_id][]'), $location['province_id'], Region::getProvinces(false), array('class' => 'form-control province', 'prompt' => '')), CHtml::error($model, 'locations.province_id.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[city_id][]', array('class' => 'col-lg-6'), CHtml::label('城市', false), CHtml::dropDownList(CHtml::activeName($model, 'locations[city_id][]'), $location['city_id'], isset($cities[$location['province_id']]) ? $cities[$location['province_id']] : array(), array('class' => 'form-control city', 'prompt' => '')), CHtml::error($model, 'locations.city_id.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[venue_zh][]', array('class' => 'col-lg-12'), CHtml::label('中文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue_zh][]'), $location['venue_zh'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue_zh.' . $key, array('class' => 'text-danger')));
            echo Html::formGroup($model, 'locations[venue][]', array('class' => 'col-lg-12'), CHtml::label('英文地址', false), CHtml::textField(CHtml::activeName($model, 'locations[venue][]'), $location['venue'], array('class' => 'form-control')), CHtml::error($model, 'locations.venue.' . $key, array('class' => 'text-danger')));
            echo CHtml::closeTag('div');
        }
        echo CHtml::closeTag('div');
        Yii::app()->clientScript->registerScript('MultiLocations', <<<EOT
  \$(document).on('click', '#addLocation', function() {
    var location = \$('.location:last').clone();
    var index = \$('.location').length + 1;
    var tab = \$('<a role="tab" data-toggle="tab">').attr('href', '#location-' + index).text('地址' + index);
    location.appendTo(\$('.locations'));
    location.find('.province').val('').trigger('change');
    location.find('input').val('');
    location.attr('id', 'location-' + index).removeClass('active');
    \$('<li>').append(
      tab
    ).insertBefore(\$('#addLocation').parent());
    tab.tab('show');
  });
EOT
);
    }
Exemple #2
0
<div class="col-lg-12">
  <?php 
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('role' => 'form', 'class' => 'form-inline'), 'method' => 'get', 'action' => array('/competition/index')));
?>
  <?php 
echo Html::formGroup($model, 'year', array(), $form->labelEx($model, 'year'), CHtml::dropDownList('year', $model->year, Competition::getYears(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'type', array(), $form->labelEx($model, 'type'), CHtml::dropDownList('type', $model->type, Competition::getTypes(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'province', array(), $form->labelEx($model, 'province'), CHtml::dropDownList('province', $model->province, Region::getProvinces(false), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <?php 
echo Html::formGroup($model, 'event', array(), $form->labelEx($model, 'event'), CHtml::dropDownList('event', $model->event, Events::getNormalTranslatedEvents(), array('class' => 'form-control', 'prompt' => Yii::t('common', 'All'))));
?>
  <button type="submit" class="btn btn-theme"><?php 
echo Yii::t('common', 'Submit');
?>
</button>
  <?php 
$this->endWidget();
?>
  <?php 
$this->widget('GridView', array('dataProvider' => $model->search(), 'template' => '{summary}{items}{pager}', 'enableSorting' => false, 'front' => true, 'emptyText' => Yii::t('Competition', 'No competitions now.'), 'rowCssClassExpression' => '$data->isInProgress() ? "success" : ($data->isEnded() ? "active" : "info")', 'columns' => array(array('name' => 'date', 'type' => 'raw', 'value' => '$data->getDisplayDate()'), array('name' => 'name', 'type' => 'raw', 'value' => '$data->getCompetitionLink()'), array('name' => 'province_id', 'type' => 'raw', 'value' => '$data->getLocationInfo("province")'), array('name' => 'city_id', 'type' => 'raw', 'value' => '$data->getLocationInfo("city")'), array('name' => 'venue', 'type' => 'raw', 'value' => '$data->getLocationInfo("venue")'))));
?>
</div>
Exemple #3
0
$form = $this->beginWidget('ActiveForm', array('htmlOptions' => array('role' => 'form')));
?>
  <?php 
if ($user->wcaid == '') {
    ?>
  <?php 
    echo Html::formGroup($model, 'wcaid', array(), $form->labelEx($model, 'wcaid'), Html::activeTextField($model, 'wcaid'), $form->error($model, 'wcaid', array('class' => 'text-danger')));
    ?>
  <?php 
}
?>
  <?php 
if ($user->country_id == 1) {
    ?>
  <?php 
    echo Html::formGroup($model, 'province_id', array('id' => 'province'), $form->labelEx($model, 'province_id'), $form->dropDownList($model, 'province_id', Region::getProvinces(), array('class' => 'form-control', 'prompt' => '')), $form->error($model, 'province_id', array('class' => 'text-danger')));
    ?>
  <?php 
    echo Html::formGroup($model, 'city_id', array('id' => 'city'), $form->labelEx($model, 'city_id'), $form->dropDownList($model, 'city_id', isset($allCities[$model->province_id]) ? $allCities[$model->province_id] : array(), array('class' => 'form-control')), $form->error($model, 'city_id', array('class' => 'text-danger')));
    ?>
  <?php 
}
?>
  <?php 
echo Html::formGroup($model, 'mobile', array(), $form->labelEx($model, 'mobile'), Html::activeTextField($model, 'mobile'), $form->error($model, 'mobile', array('class' => 'text-danger')));
?>
  <p class="text-info"><?php 
echo Yii::t('common', 'Please contact the adminstrator via {email} for changing the other personal information.', array('{email}' => CHtml::mailto(Html::fontAwesome('envelope', 'a') . Yii::app()->params->adminEmail, Yii::app()->params->adminEmail)));
?>
</p>
  <button type="submit" class="btn btn-theme btn-lg"><?php