Some enhancements

After trying yii (1.0.4, 1.0.5 and 1.0.6) and doing some personalizations and tests, I decided to reset everything, download 1.0.7 version and see how it tastes. So, I have made some observations

* When I run model command:

  • Now Yii have the possibility to remove table prefixes from model name(tbl_user => user). Good! But, It is missing an options to remove table prefix from columns to generate labels. For example, columns in my user table are named user_id, user_name, user_job, user_password, etc.

  • Imagine that I want to show my User list as ‘Company Users list’. I think it is appropriated that I have an option to rename ‘User’ with the alias of my wish. It can happen at anytime.

So, I think that it would be useful if yiic command becomes as below:




>> model tbl_user User --alias="Company users" --column-prefix="user_"



Or something alike. The command above would generate the following model:




class User extends CActiveRecord{


    public function tableName(){

	return 'tbl_user';

    }


    public function aliasName(){

        return 'Company Users';

    }


    public function attributeLabels(){

	return array(

		'user_id'=>'Id',

                'user_name'=>'Name',

                ...

        );

    }

}



If I change aliasName, it would reflect in every view of mine. This leads me to the next topic:

* When I run crud command:

Yii generates to me the ‘create’,‘update’,‘list’,‘show’,‘admin’ and ‘_form’ views.

  • I think this actions should be internationalizated. Actual page titles are like ‘Show User’, where ‘Show’ is the action name. I want to change the language and automatically change the page title. Actually this is not possible.

  • Inside views, there’s too many fixed information not internationalizated.

For example, inside _form.php:


<p>

Fields with <span class="required">*</span> are required.

</p>

I think this should be generated like:


<p>

Yii::t('Fields with <span class="required">*</span> are required').

</p>

Another example (in _form.php):


<div class="action">

<?php echo "<?php echo CHtml::submitButton(\$update ? 'Save' : 'Create'); ?>\n"; ?>

</div>

It should be:


<div class="action">

<?php echo "<?php echo CHtml::submitButton(\'".Yii::t($update?"Save":"Create")."'); ?>\n"; ?>

</div>

One more example (in admin.php):


[<?php echo CHtml::link('material List',array('list')); ?>]

It should be composed by ‘alias’ + ‘action’:


[<?php echo CHtml::link(strtr(Yii::t('yii', "{model} List"), array("{model}" => $model->aliasName())), array(Yii::t('yii', 'list'))); ?>]

Ok, not so readable, but the "List" word cannot be static. Maybe CHtml::link should do the translation automatically?

At least at portuguese forum I see many users with problems to do these translations. It spends a significant time. I think the changes above should end these problems and make yii ready-to-use for non-english developers.

Well, I know that I can extend Yii to my needs, but I have problems every Yii update. It would be better that something could be part of the core standard or something similar could be done (as done with table prefix).

Thanks for the attention!

Yes, there are many ways to enhance the crud command. As a matter of fact, it is impossible to make a crud command that fits for all needs. For this reason, the crud command is designed to be extensible. Please refer to http://www.yiiframework.com/doc/cookbook/41/ on how to create your own crud templates. It should solve all your problems listed.

I see. Well, the things i listed are not disturbing me, as I have my CRUD templates. I’d like to have it in the core to make easier when update to a new Yii version. And make Yii more “ready-to-use” to non-english new users.

What do you think if I make CRUD adaptations for my language and put it to download as an extension?

Sure. Providing a modified CRUD is certainly an extension that may be liked by many people.