Qiang Xue
11 years ago
6 changed files with 174 additions and 83 deletions
@ -1,49 +1,45 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
|
use yii\helpers\Inflector; |
||||||
|
use yii\helpers\StringHelper; |
||||||
|
|
||||||
/** |
/** |
||||||
* The following variables are available in this template: |
* @var yii\base\View $this |
||||||
* - $this: the CrudCode object |
* @var yii\gii\generators\crud\Generator $generator |
||||||
*/ |
*/ |
||||||
?> |
|
||||||
<?php echo "<?php\n"; ?> |
|
||||||
/* @var $this <?php echo $this->getControllerClass(); ?> */
|
|
||||||
/* @var $model <?php echo $this->getModelClass(); ?> */
|
|
||||||
/* @var $form CActiveForm */ |
|
||||||
?> |
|
||||||
|
|
||||||
<div class="form"> |
/** @var \yii\db\ActiveRecord $model */ |
||||||
|
$class = $generator->modelClass; |
||||||
<?php echo "<?php \$form=\$this->beginWidget('CActiveForm', array(
|
$model = new $class; |
||||||
'id'=>'".$this->class2id($this->modelClass)."-form', |
$safeAttributes = $model->safeAttributes(); |
||||||
// Please note: When you enable ajax validation, make sure the corresponding |
if (empty($safeAttributes)) { |
||||||
// controller action is handling ajax validation correctly. |
$safeAttributes = $model->getTableSchema()->columnNames; |
||||||
// There is a call to performAjaxValidation() commented in generated controller code. |
} |
||||||
// See class documentation of CActiveForm for details on this. |
|
||||||
'enableAjaxValidation'=>false, |
|
||||||
)); ?>\n"; ?> |
|
||||||
|
|
||||||
<p class="note">Fields with <span class="required">*</span> are required.</p> |
echo "<?php\n";
|
||||||
|
?> |
||||||
|
|
||||||
<?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?> |
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
<?php |
/** |
||||||
foreach($this->tableSchema->columns as $column) |
* @var yii\base\View $this |
||||||
{ |
* @var <?php echo ltrim($generator->modelClass, '\\'); ?> $model
|
||||||
if($column->autoIncrement) |
* @var yii\widgets\ActiveForm $form |
||||||
continue; |
*/ |
||||||
?> |
?> |
||||||
<div class="row"> |
|
||||||
<?php echo "<?php echo ".$this->generateActiveLabel($this->modelClass,$column)."; ?>\n"; ?> |
|
||||||
<?php echo "<?php echo ".$this->generateActiveField($this->modelClass,$column)."; ?>\n"; ?> |
|
||||||
<?php echo "<?php echo \$form->error(\$model,'{$column->name}'); ?>\n"; ?> |
|
||||||
</div> |
|
||||||
|
|
||||||
<?php |
<div class="<?php echo Inflector::camel2id(StringHelper::basename($generator->modelClass)); ?>-form">
|
||||||
} |
|
||||||
?> |
<?php echo '<?php'; ?> $form = ActiveForm::begin(); ?>
|
||||||
<div class="row buttons"> |
|
||||||
<?php echo "<?php echo CHtml::submitButton(\$model->isNewRecord ? 'Create' : 'Save'); ?>\n"; ?> |
<?php foreach ($safeAttributes as $attribute) { |
||||||
</div> |
echo "\t\t<?php echo " . $generator->generateActiveField($model, $attribute) . " ?>\n\n";
|
||||||
|
} ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo '<?php'; ?> echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', array('class' => 'btn btn-primary')); ?>
|
||||||
|
</div> |
||||||
|
|
||||||
<?php echo "<?php \$this->endWidget(); ?>\n"; ?> |
<?php echo '<?php'; ?> ActiveForm::end(); ?>
|
||||||
|
|
||||||
</div><!-- form --> |
</div> |
||||||
|
@ -1,29 +1,54 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
|
use yii\helpers\Inflector; |
||||||
|
use yii\helpers\StringHelper; |
||||||
|
|
||||||
/** |
/** |
||||||
* The following variables are available in this template: |
* @var yii\base\View $this |
||||||
* - $this: the CrudCode object |
* @var yii\gii\generators\crud\Generator $generator |
||||||
*/ |
*/ |
||||||
?> |
|
||||||
<?php echo "<?php\n"; ?> |
|
||||||
/* @var $this <?php echo $this->getControllerClass(); ?> */
|
|
||||||
/* @var $dataProvider CActiveDataProvider */ |
|
||||||
|
|
||||||
<?php |
/** @var \yii\db\ActiveRecord $model */ |
||||||
$label=$this->pluralize($this->class2name($this->modelClass)); |
$class = $generator->modelClass; |
||||||
echo "\$this->breadcrumbs=array( |
$pks = $class::primaryKey(); |
||||||
'$label', |
if (count($pks) === 1) { |
||||||
);\n"; |
$viewUrl = "array('view', 'id' => \$model->{$pks[0]})"; |
||||||
|
} else { |
||||||
|
$params = array(); |
||||||
|
foreach ($pks as $pk) { |
||||||
|
$params[] = "'$pk' => \$model->$pk"; |
||||||
|
} |
||||||
|
$viewUrl = "array('view', " . implode(', ', $params) . ')'; |
||||||
|
} |
||||||
|
|
||||||
|
$nameAttribute = $generator->getNameAttribute(); |
||||||
|
|
||||||
|
echo "<?php\n";
|
||||||
?> |
?> |
||||||
|
|
||||||
$this->menu=array( |
use yii\helpers\Html; |
||||||
array('label'=>'Create <?php echo $this->modelClass; ?>', 'url'=>array('create')),
|
use <?php echo $generator->indexWidgetType === 'grid' ? 'yii\grid\GridView' : 'yii\widgets\ListView'; ?>;
|
||||||
array('label'=>'Manage <?php echo $this->modelClass; ?>', 'url'=>array('admin')),
|
|
||||||
); |
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\data\ActiveDataProvider $dataProvider |
||||||
|
*/ |
||||||
|
|
||||||
|
$this->title = '<?php echo Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass))); ?>';
|
||||||
?> |
?> |
||||||
|
<div class="<?php echo Inflector::camel2id(StringHelper::basename($generator->modelClass)); ?>-index">
|
||||||
|
|
||||||
|
<h1><?php echo "<?php"; ?> echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<?php if ($generator->indexWidgetType === 'grid'): ?> |
||||||
|
|
||||||
<h1><?php echo $label; ?></h1>
|
<?php else: ?> |
||||||
|
<?php echo "\t<?php"; ?> echo ListView::widget(array(
|
||||||
|
'dataProvider' => $dataProvider, |
||||||
|
'itemView' => function ($model, $key, $index, $widget) { |
||||||
|
return Html::a(Html::encode($model-><?php echo $nameAttribute; ?>), <?php echo $viewUrl; ?>);
|
||||||
|
}, |
||||||
|
)); ?> |
||||||
|
<?php endif; ?> |
||||||
|
|
||||||
<?php echo "<?php"; ?> $this->widget('zii.widgets.CListView', array(
|
</div> |
||||||
'dataProvider'=>$dataProvider, |
|
||||||
'itemView'=>'_view', |
|
||||||
)); ?> |
|
||||||
|
Loading…
Reference in new issue