add autocomplete for model class field

This commit is contained in:
mitalcoi
2014-06-12 00:17:16 +04:00
parent 8e5f5fe8f5
commit 5fdef858ce
2 changed files with 24 additions and 0 deletions

View File

@@ -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'));

View File

@@ -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);
}
}