Commit 220db270 by Qiang Xue

Improved crud generator.

parent f3504f42
......@@ -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(
......
......@@ -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,
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment