mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 23:43:19 +08:00
add autocomplete for model class field
This commit is contained in:
@@ -151,6 +151,21 @@ yii.gii = (function ($) {
|
|||||||
$('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1);
|
$('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1);
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
|
//model generator: translate table name to model class
|
||||||
|
$('#generator-tablename').on('blur', function () {
|
||||||
|
var tableName = $(this).val();
|
||||||
|
if (tableName && tableName !== '*'){
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "default/classify",
|
||||||
|
data: {tableName: tableName},
|
||||||
|
success: function (modelName) {
|
||||||
|
$('#generator-modelclass').val(modelName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// hide message category when I18N is disabled
|
// hide message category when I18N is disabled
|
||||||
$('form #generator-enablei18n').change(function () {
|
$('form #generator-enablei18n').change(function () {
|
||||||
$('form .field-generator-messagecategory').toggle($(this).is(':checked'));
|
$('form .field-generator-messagecategory').toggle($(this).is(':checked'));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
namespace yii\gii\controllers;
|
namespace yii\gii\controllers;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\helpers\Inflector;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
@@ -126,4 +127,12 @@ class DefaultController extends Controller
|
|||||||
throw new NotFoundHttpException("Code generator not found: $id");
|
throw new NotFoundHttpException("Code generator not found: $id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $tableName
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function actionClassify($tableName){
|
||||||
|
return Inflector::classify($tableName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user