how to generate a textfield with customized height (yii textField)
10,153
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;',
));
Author by
Gunnit
Updated on June 04, 2022Comments
-
Gunnit almost 2 years
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
-
topher about 11 yearsThis answer is correct apart from an error at
'style'=>'width:600px'
in the 2nd and 3rd code blocks -
Ionut Flavius Pogacian about 11 yearsyeah, thanks, i was in a hurry, just leaving the office when i saw this article; fixed