Browse Source

automatically hide model class input if needed.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
f87e4ce604
  1. 5
      framework/yii/gii/assets/gii.js
  2. 2
      framework/yii/gii/controllers/DefaultController.php
  3. 5
      framework/yii/gii/views/default/view.php

5
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();

2
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();

5
framework/yii/gii/views/default/view.php

@ -28,7 +28,10 @@ foreach ($generator->templates as $name => $path) {
<p><?php echo $generator->getDescription(); ?></p>
<?php $form = ActiveForm::begin(array('fieldConfig' => array('class' => ActiveField::className()))); ?>
<?php $form = ActiveForm::begin(array(
'id' => "$id-generator",
'fieldConfig' => array('class' => ActiveField::className()),
)); ?>
<div class="row">
<div class="col-lg-8">
<?php echo $this->renderFile($generator->formView(), array(

Loading…
Cancel
Save