Changing default styling on form textInputs generated by Gii

How can I change the height and width on a field in a table view (textInput) so that the text entry starts at the top left, and wraps when you reach the end of the line.

In my view’s form file: views/employees/_form.php

I changed:


<?= $form->field($model, 'writeups')->textInput(['maxlength' => true]) ?>

to:


<?= $form->field($model, 'writeups')->textInput(['maxlength' => true, 'style'=>'height:300px']) ?>

This changed the height of the textInput but the text was centered vertically, rather than starting at the top right corner.

I am guessing I can create a CSS class and add it somehow. Is there a standard way of doing this in Yii?

Thanks,

Sam

Ugh… sorry if I am spamming the forums here. I figured this one out.

Change textInput to textArea and the text will start at the top left, and it will wrap.

If someone could let me know if there is a way if you can let Gii know to use textArea’s instead of inputs for specific fields, or types of fields, before the automatic code generation takes place, that would be great. For instance, can I apply some formula to make it a textArea for any varchar field in the db of a given size, and give it a height relative to that size (maybe for every 200 chars or something you make the height increase by one line-height unit) that would be awesome.

Sam

Have you considered textArea?




<?php echo $form->textArea($model, 'writeups', array('maxlength' => true, 'rows' => 6, 'cols' => 50));



The numbers are arbitrary but you can experiment.

Guess you beat me to it. Customizing gii is more involved.

Thanks newbiedo anyway!

If you only have so many models and forms to create for them, you may just have to paste in or type in the textarea code.