Dynamically width of CActiveForm elements

Is there a way to set dynamically the width of CActiveForm elements based on number of characters in the fields of the database? Example: field gg_user.user_name(varchar(20) and the textbox has been set with 20 of width automatically.

Thanks!

You would have to get to your table schema to get information about your fields’ length. In most situations Yii does it internally. I don’t think, that doing, what you want to do is an easy task and I’m thinking, if the effect, you’ll receive is worth complicating life like that? :]

Sorry, not much help here.

Yii automatically sets maxlength for text fields if you have a “length” validation rule (see activeInputField method). I think you need not 20px width but size=20? I don’t think it’s a good idea though, because fields look better when they have the same size (just imo of course), but there is no an elegant way to override CHtml::activeInputField(), because it’s a static function.

Thank you very much for your reply!

I´m was thinking about the width of elements in px not in max number of caracters allowed, but thank you very much for your reply!