how to generate a textfield with customized height

2019-05-11 04:26发布

Hello everybody and thanks for reading. I have this

   <?php
                echo $form->textField($model, 'link', array(
                    'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
                    'class' => 'span12', 'maxlength' => 999, 
                    'height'=>100, 
                    'htmlOptions' => array('style' => 'height:60px;font-size: 22px;')
                    ));
                ?>

This is not working for width but when i replace it with height its not working. There is no other css rules that overwrite it . How can i set a custom height on a textfiled in yii

标签: css yii
2条回答
别忘想泡老子
2楼-- · 2019-05-11 04:36

from yii docs:

public string textField(CModel $model, string $attribute, array $htmlOptions=array ( ))

so you should have:

$form->textfield($model,'link',array('style'=>'width:600px;'));

i see that you also have a class:

$form->textfield($model,'link',array('style'=>'width:600px;', 'class' => 'class_x'));

now, let me explin what happens within your code:

echo $form->textField($model, 'link', array(
                    'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
                    'class' => 'span12', 'maxlength' => 999, 
                    'height'=>100, 
                    'htmlOptions' => array('style' => 'height:60px;font-size: 22px;')
                    ));

the first and second parameters are ok

when it comes to the 3rd one, at first it looks fine, because it is a array, that represents the htmlOptions array from the documentation

if you digg deeper, you see that in the htmlOptions array you have another htmlOptions array; WHY?

write like this:

echo $form->textField($model, 'link', array(
                    'prepend' => '<i class="icon-4x icon-globe" style="line-height: 54px;"></i>',
                    'class' => 'span12',
                    'style' => 'height:60px;font-size: 22px;width:999px;',
                    ));
查看更多
疯言疯语
3楼-- · 2019-05-11 04:53

You can use something like:

echo $form->textField($model,'link',array('size'=>50,'maxlength'=>50,));
查看更多
登录 后发表回答