Пример #1
0
	/**
	 * Generates and returns the array (as a PHP source code string)
	 * to collect the MANY_MANY related data from the POST.
	 * @param string $modelClass The model class name.
	 * @return string The source code to collect the MANY_MANY related
	 * data from the POST.
	 */
	public function generateGetPostRelatedData($modelClass, $indent = 1) {
		$result = array();
		$relations = $this->getRelations($modelClass);
		foreach ($relations as $relationData) {
			$relationName = $relationData[0];
			$relationType = $relationData[1];
			if ($relationType == GxActiveRecord::MANY_MANY)
				$result[$relationData[0]] = "php:\$_POST['{$modelClass}']['{$relationName}'] === '' ? null : \$_POST['{$modelClass}']['{$relationName}']";
		}
		return GxCoreHelper::ArrayToPhpSource($result, $indent);
	}
Пример #2
0
Yii::app()->clientScript->registerScript('gii.crud', "\n\$('#{$class}_controller').change(function(){\n\t\$(this).data('changed',\$(this).val()!='');\n});\n\$('#{$class}_model').bind('keyup change', function(){\n\tvar controller=\$('#{$class}_controller');\n\tif(!controller.data('changed')) {\n\t\tvar id=new String(\$(this).val().match(/\\w*\$/));\n\t\tif(id.length>0)\n\t\t\tid=id.substring(0,1).toLowerCase()+id.substring(1);\n\t\tcontroller.val(id);\n\t}\n});\n");
?>
<h1>giix 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 sticky">
		<?php 
echo $form->labelEx($model, 'moduleName');
?>
		<?php 
echo $form->dropDownList($model, 'moduleName', GxCoreHelper::getModuleList(), array('options' => array($model->moduleName => array('selected' => true))));
?>
		<div class="tooltip">
		This refers to the module name that will contain the model.
		Setting this property mainly affects where model classes are generated.
		For example, a module name <code>Comments</code> will generate the model in the path 
		<code>application.modules.comments.models</code>.
		<br/>
		Leave this field empty if your model does not belong to any module..
		</div>
		<?php 
echo $form->error($model, 'moduleName');
?>
	</div>

	<div class="row">