yii - Gii CRUD generator and related tables -


i using yii framework , have got problem crud generator. have got 2 tables called users , news following structures:

create table if not exists `news` (   `id` int(11) not null auto_increment,   `keyword` varchar(1000) collate utf8_persian_ci default null,   `user_id` tinyint(3) unsigned not null,   `title` varchar(100) collate utf8_persian_ci default null,   `body` varchar(1000) collate utf8_persian_ci default null,   `publishedat` date default null,   `state` tinyint(1) unsigned default null,   `archive` tinyint(1) unsigned default null,   `last_modified` datetime default null,   primary key (`id`),   key `news_fkindex1` (`keyword`(255)),   key `news_fkindex2` (`user_id`) ) engine=innodb  default charset=utf8 collate=utf8_persian_ci auto_increment=3 ;     create table if not exists `users` (   `id` int(11) not null auto_increment,   `username` varchar(20) not null,   `password` varchar(128) not null,   `create_at` timestamp not null default current_timestamp,   `lastvisit_at` timestamp null default null,   `is_disabled` tinyint(1) not null default '1',   primary key (`id`),   unique key `username` (`username`),   key `status` (`is_disabled`) ) engine=innodb  default charset=utf8 auto_increment=7 ; 

when generate crud using gii news table cannot see fields users table. instead of user_id want see username in table created crud generator. how can make change in code result above?

first, user_id needs foreign key field not key field.

second, gii not generate field require default. such functionality extension such giix might help. however, since relation exists use relationname.username display username in grid view or list view.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -