Commit 5fdef858 by mitalcoi

add autocomplete for model class field

parent 8e5f5fe8
......@@ -151,6 +151,21 @@ yii.gii = (function ($) {
$('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1);
}).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
$('form #generator-enablei18n').change(function () {
$('form .field-generator-messagecategory').toggle($(this).is(':checked'));
......
......@@ -8,6 +8,7 @@
namespace yii\gii\controllers;
use Yii;
use yii\helpers\Inflector;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
......@@ -126,4 +127,12 @@ class DefaultController extends Controller
throw new NotFoundHttpException("Code generator not found: $id");
}
}
/**
* @param string $tableName
* @return string
*/
public function actionClassify($tableName){
return Inflector::classify($tableName);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment