index.php 3.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
<?php
$class = get_class($model);
Yii::app()->clientScript->registerScript('gii.crud', "
$('#{$class}_controller').change(function(){
	$(this).data('changed', $(this).val() != '');
});
$('#{$class}_model').bind('keyup change', function(){
	var controller = $('#{$class}_controller');
	if (!controller.data('changed'))
	{
		var id = new String($(this).val().match(/\\w*$/));
		if (id.length > 0)
		{
			id = id.substring(0, 1).toLowerCase() + id.substring(1);
		}
		controller.val(id);
	}
});
");
?>
<h1>Web App Theme Crud Generator</h1>
<p>This generator generates a controller and views that implement CRUD operations for the specified data model.</p>
<?php $form = $this->beginWidget('CCodeForm', array(
	'model' => $model,
)); ?>
	<div class="row">
		<?php echo $form->labelEx($model, 'model'); ?>
		<?php echo $form->textField($model, 'model', array('size' => 65)); ?>
		<div class="tooltip">
			Model class is case-sensitive. It can be either a class name (e.g. <code>Post</code>)
			or the path alias of the class file (e.g. <code>application.models.Post</code>).
			Note that if the former, the class must be auto-loadable.
		</div>
		<?php echo $form->error($model, 'model'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model, 'controller'); ?>
		<?php echo $form->textField($model, 'controller', array('size' => 65)); ?>
		<div class="tooltip">
			Controller ID is case-sensitive. CRUD controllers are often named after
			the model class name that they are dealing with. Below are some examples:
			<ul>
				<li><code>post</code> generates <code>PostController.php</code></li>
				<li><code>postTag</code> generates <code>PostTagController.php</code></li>
				<li><code>admin/user</code> generates <code>admin/UserController.php</code>.
					If the application has an <code>admin</code> module enabled,
					it will generate <code>UserController</code> (and other CRUD code)
					within the module instead.
				</li>
			</ul>
		</div>
		<?php echo $form->error($model, 'controller'); ?>
	</div>
	<div class="row sticky">
		<?php echo $form->labelEx($model, 'baseControllerClass'); ?>
		<?php echo $form->textField($model, 'baseControllerClass', array('size' => 65)); ?>
		<div class="tooltip">
			This is the class that the new CRUD controller class will extend from.
			Please make sure the class exists and can be autoloaded.
		</div>
		<?php echo $form->error($model, 'baseControllerClass'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model, 'generateComponents'); ?>
		<?php echo $form->checkBox($model, 'generateComponents'); ?>
		<div class="tooltip">
			Whether additional components and widgets that override default one should be generated.
		</div>
		<?php echo $form->error($model, 'generateComponents'); ?>
	</div>
	<div class="row sticky">
		<?php echo $form->labelEx($model, 'layoutPrefix'); ?>
		<?php echo $form->textField($model, 'layoutPrefix', array('size' => 65)); ?>
		<div class="tooltip">
			This refers to the directory that the new layout file should be generated under.
			It should be specified in the form of a path alias relatively to the base layouts directory, for example, <code>admin.ext</code>.
		</div>
		<?php echo $form->error($model, 'layoutPrefix'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model, 'generateLayouts'); ?>
		<?php echo $form->checkBox($model, 'generateLayouts'); ?>
		<div class="tooltip">
			Whether layouts should be generated.
		</div>
		<?php echo $form->error($model, 'generateLayouts'); ?>
	</div>
	<div class="row sticky">
		<?php echo $form->labelEx($model, 'theme'); ?>
		<?php echo $form->dropDownList($model, 'theme', $model->getThemes(), array('style' => 'width: 420px')); ?>
		<div class="tooltip">
			Please select which theme should be used to generate the layout.
		</div>
		<?php echo $form->error($model, 'theme'); ?>
	</div>
<?php $this->endWidget(); ?>