Browse Source

Improved crud generator.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
220db270cf
  1. 8
      framework/yii/gii/generators/crud/templates/views/index.php
  2. 4
      framework/yii/gii/generators/crud/templates/views/view.php
  3. 11
      framework/yii/grid/DataColumn.php

8
framework/yii/gii/generators/crud/templates/views/index.php

@ -30,13 +30,11 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?php echo "<?php"; ?> echo Html::encode($this->title); ?></h1>
<?php echo '<?php'; ?> echo $this->render('_search', array('model' => $searchModel)); ?>
<?php echo '<?php' . ($generator->indexWidgetType === 'grid' ? ' //' : ''); ?> echo $this->render('_search', array('model' => $searchModel)); ?>
<hr>
<div>
<p>
<?php echo '<?php'; ?> echo Html::a('Create <?php echo StringHelper::basename($generator->modelClass); ?>', array('create'), array('class' => 'btn btn-danger')); ?>
</div>
</p>
<?php if ($generator->indexWidgetType === 'grid'): ?>
<?php echo "<?php"; ?> echo GridView::widget(array(

4
framework/yii/gii/generators/crud/templates/views/view.php

@ -29,14 +29,14 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?php echo "<?php"; ?> echo Html::encode($this->title); ?></h1>
<div>
<p>
<?php echo '<?php'; ?> echo Html::a('Update', array('update', <?php echo $urlParams; ?>), array('class' => 'btn btn-danger')); ?>
<?php echo '<?php'; ?> echo Html::a('Delete', array('delete', <?php echo $urlParams; ?>), array(
'class' => 'btn btn-danger',
'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'data-method' => 'post',
)); ?>
</div>
</p>
<?php echo '<?php'; ?> echo DetailView::widget(array(
'model' => $model,

11
framework/yii/grid/DataColumn.php

@ -68,6 +68,12 @@ class DataColumn extends Column
* - If you don't want a filter for this data column, set this value to be false.
*/
public $filter;
/**
* @var array the HTML attributes for the filter input fields. This property is used in combination with
* the [[filter]] property. When [[filter]] is not set or is an array, this property will be used to
* render the HTML attributes for the generated filter input fields.
*/
public $filterInputOptions = array('class' => 'form-control');
protected function renderHeaderCellContent()
@ -111,9 +117,10 @@ class DataColumn extends Column
return $this->filter;
} elseif ($this->filter !== false && $this->grid->filterModel instanceof Model && $this->attribute !== null) {
if (is_array($this->filter)) {
return Html::activeDropDownList($this->grid->filterModel, $this->attribute, $this->filter, array('prompt' => ''));
$options = array_merge(array('prompt' => ''), $this->filterInputOptions);
return Html::activeDropDownList($this->grid->filterModel, $this->attribute, $this->filter, $options);
} else {
return Html::activeTextInput($this->grid->filterModel, $this->attribute);
return Html::activeTextInput($this->grid->filterModel, $this->attribute, $this->filterInputOptions);
}
} else {
return parent::renderFilterCellContent();

Loading…
Cancel
Save