Improvement of Cli model command

I've extended a little bit a ModelCommand, to fill attributeLabels with column name. I think this is really useful when we have a table with a lot of column, below you will find patch files.

model view file

ModelCommand

Actually you don't need to declare every label in attributeLabels() if it can be generated automatically using getAttributeLabel().

I think you've missunderstood my idea. We are using getAttributeLabel() to have personalized text for labels. If column names are fine for us, there is no problem - this is not needed. But what, when we want to customize (almost) every column name displayed using label? When the amount of column is big, there is really a time waste for writing manually all column names. We can also easily do a typo. My example will generate this:

Now, I can easily customize a column name and I’m not forced to remember every column name. Commands should be more less-code-writting-oriented :)

That will be a great feature to add.  Can we incorporate this right away since this is something we will have to do for every table?

May be when we got to web based yiic, we should have "system" tables that can pre-populate this and be able to edit this as required - may be even leave this dynamic so it can be changed without changing code.

When I posted this suggestion, I've in mind, that a lot of people is creating sties, which has more than

one language and at least they are using the same model several times in another context.

Second thing is that a lot of us (e.g. I) creates SQL tables using english names for column. Therefore

when we are creating application in native language, we have to define new labels.

If tables has a lot of columns it is really a waste of time to write content of getAttributeLabel manually

when this can be done automatically. At the end we have to change only description.

@qiang: maybe my example was a little bit confusing. Let's say that it wiil be looking after model

generation in following way:



	return array(


		/* uncoment this to bind customized label description to column name


			


			'id'=>'id',


			'description'=>'?',


			'bye_victory_score'=>'?',


			'bye_defeat_score'=>'?',


                                       //a lot of toher columns there


			'points_for_bilateral_walkover'=>'?',


	    */


		);


I agree with aztech that manually writing getAttributeLabel is a waste of time,especially when you are dealing with dozens of tables. Actually I have written my own patches for model shell. One suggestion, with the i18 in mind, I did it a little bit further by adding Yii::t() to the attributes' name and. So the output would look like:

	





return array(


'column_name'=>Yii::t(__CLASS__,'column_name'),


...


);

I hope it will be helpful for some of you guys.

Quote

Therefore

when we are creating application in native language, we have to define new labels.

If tables has a lot of columns it is really a waste of time to write content of getAttributeLabel manually

when this can be done automatically.

I think so as well. vote++

Could you please submit a ticket for this? Thanks!

Is it better to have a blank string instead? I am propsing this

Quote

'id'=>'',

'description'=>'',

'bye_victory_score'=>'',

'bye_defeat_score'=>'',

than

Quote

'id'=>'id',

'description'=>'description',

'bye_victory_score'=>'bye_victory_score',

'bye_defeat_score'=>'bye_defeat_score',

, because we have to erase those strings first when we need to change the text anyway. Or, may be you guys are using a better text editor…

This feature has been implemented in SVN.

Confirmed, thanks Qiang. May be my idea is not suitable for the default action…