From f87e4ce6042338328b9d3bc3ddd516f4b6d5ea0a Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 31 Aug 2013 18:47:30 -0400 Subject: [PATCH] automatically hide model class input if needed. --- framework/yii/gii/assets/gii.js | 5 +++++ framework/yii/gii/controllers/DefaultController.php | 2 +- framework/yii/gii/views/default/view.php | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/framework/yii/gii/assets/gii.js b/framework/yii/gii/assets/gii.js index 284006e..b581d3b 100644 --- a/framework/yii/gii/assets/gii.js +++ b/framework/yii/gii/assets/gii.js @@ -76,6 +76,11 @@ yii.gii = (function ($) { initPreviewDiffLinks(); initConfirmationCheckboxes(); + // model generator: hide class name input when table name input contains * + $('#model-generator #generator-tablename').on('change', function () { + $('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1); + }).change(); + // hide Generate button if any input is changed $('.default-view .form-group input,select,textarea').change(function () { $('.default-view-results,.default-view-files').hide(); diff --git a/framework/yii/gii/controllers/DefaultController.php b/framework/yii/gii/controllers/DefaultController.php index 9bc444e..969096b 100644 --- a/framework/yii/gii/controllers/DefaultController.php +++ b/framework/yii/gii/controllers/DefaultController.php @@ -35,7 +35,7 @@ class DefaultController extends Controller public function actionView($id) { $generator = $this->loadGenerator($id); - $params = array('generator' => $generator); + $params = array('generator' => $generator, 'id' => $id); if (isset($_POST['preview']) || isset($_POST['generate'])) { if ($generator->validate()) { $generator->saveStickyAttributes(); diff --git a/framework/yii/gii/views/default/view.php b/framework/yii/gii/views/default/view.php index 1782c77..c61d5d0 100644 --- a/framework/yii/gii/views/default/view.php +++ b/framework/yii/gii/views/default/view.php @@ -28,7 +28,10 @@ foreach ($generator->templates as $name => $path) {

getDescription(); ?>

- array('class' => ActiveField::className()))); ?> + "$id-generator", + 'fieldConfig' => array('class' => ActiveField::className()), + )); ?>
renderFile($generator->formView(), array(