6 changed files with 174 additions and 83 deletions
			
			
		@ -1,49 +1,45 @@
					 | 
				
			||||
<?php | 
				
			||||
 | 
				
			||||
use yii\helpers\Inflector; | 
				
			||||
use yii\helpers\StringHelper; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * The following variables are available in this template: | 
				
			||||
 * - $this: the CrudCode object | 
				
			||||
 * @var yii\base\View $this | 
				
			||||
 * @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"> | 
				
			||||
 | 
				
			||||
<?php echo "<?php \$form=\$this->beginWidget('CActiveForm', array(
 | 
				
			||||
	'id'=>'".$this->class2id($this->modelClass)."-form', | 
				
			||||
	// Please note: When you enable ajax validation, make sure the corresponding | 
				
			||||
	// controller action is handling ajax validation correctly. | 
				
			||||
	// There is a call to performAjaxValidation() commented in generated controller code. | 
				
			||||
	// See class documentation of CActiveForm for details on this. | 
				
			||||
	'enableAjaxValidation'=>false, | 
				
			||||
)); ?>\n"; ?> | 
				
			||||
/** @var \yii\db\ActiveRecord $model */ | 
				
			||||
$class = $generator->modelClass; | 
				
			||||
$model = new $class; | 
				
			||||
$safeAttributes = $model->safeAttributes(); | 
				
			||||
if (empty($safeAttributes)) { | 
				
			||||
	$safeAttributes = $model->getTableSchema()->columnNames; | 
				
			||||
} | 
				
			||||
 | 
				
			||||
	<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) | 
				
			||||
{ | 
				
			||||
	if($column->autoIncrement) | 
				
			||||
		continue; | 
				
			||||
/** | 
				
			||||
 * @var yii\base\View $this | 
				
			||||
 * @var <?php echo ltrim($generator->modelClass, '\\'); ?> $model
 | 
				
			||||
 * @var yii\widgets\ActiveForm $form | 
				
			||||
 */ | 
				
			||||
?> | 
				
			||||
	<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="row buttons"> | 
				
			||||
		<?php echo "<?php echo CHtml::submitButton(\$model->isNewRecord ? 'Create' : 'Save'); ?>\n"; ?> | 
				
			||||
<div class="<?php echo Inflector::camel2id(StringHelper::basename($generator->modelClass)); ?>-form">
 | 
				
			||||
 | 
				
			||||
	<?php echo '<?php'; ?> $form = ActiveForm::begin(); ?>
 | 
				
			||||
 | 
				
			||||
<?php foreach ($safeAttributes as $attribute) { | 
				
			||||
	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 | 
				
			||||
 | 
				
			||||
use yii\helpers\Inflector; | 
				
			||||
use yii\helpers\StringHelper; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * The following variables are available in this template: | 
				
			||||
 * - $this: the CrudCode object | 
				
			||||
 * @var yii\base\View $this | 
				
			||||
 * @var yii\gii\generators\crud\Generator $generator | 
				
			||||
 */ | 
				
			||||
?> | 
				
			||||
<?php echo "<?php\n"; ?> | 
				
			||||
/* @var $this <?php echo $this->getControllerClass(); ?> */
 | 
				
			||||
/* @var $dataProvider CActiveDataProvider */ | 
				
			||||
 | 
				
			||||
<?php | 
				
			||||
$label=$this->pluralize($this->class2name($this->modelClass)); | 
				
			||||
echo "\$this->breadcrumbs=array( | 
				
			||||
	'$label', | 
				
			||||
);\n"; | 
				
			||||
/** @var \yii\db\ActiveRecord $model */ | 
				
			||||
$class = $generator->modelClass; | 
				
			||||
$pks = $class::primaryKey(); | 
				
			||||
if (count($pks) === 1) { | 
				
			||||
	$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( | 
				
			||||
	array('label'=>'Create <?php echo $this->modelClass; ?>', 'url'=>array('create')),
 | 
				
			||||
	array('label'=>'Manage <?php echo $this->modelClass; ?>', 'url'=>array('admin')),
 | 
				
			||||
); | 
				
			||||
use yii\helpers\Html; | 
				
			||||
use <?php echo $generator->indexWidgetType === 'grid' ? 'yii\grid\GridView' : 'yii\widgets\ListView'; ?>;
 | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * @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(
 | 
				
			||||
	'dataProvider'=>$dataProvider, | 
				
			||||
	'itemView'=>'_view', | 
				
			||||
)); ?> | 
				
			||||
</div> | 
				
			||||
					 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue