Yii Framework Forum: Custom Textfield Type - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Custom Textfield Type Rate Topic: -----

#1 User is offline   Ɓukasz Piotrowski 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-September 12

Posted 18 September 2012 - 09:22 AM


I would like integrate my bootstrap with my Yii. I download extension, install but i would like keep my old layout text field.

When i explore my code, i saw that I have problem because yii set default type text in textfield, and my textfield is extends about bootstrap style.

Fortunately, I found a solution, and I think that one might be to think about it:

I create in CHtml class and in CActiveForm new method to set text field with not default value:


public function textTypeField($model,$attribute,$type,$htmlOptions=array())
    return Chtml::activeTextField($model,attribute,$type,$type,$htmlOptions);


public function activeTypeTextField($model,$attribute,$type,$htmlOptions=array())
    return self::activeInputField($type,$model,$attribute,$htmlOptions);

This resolve problem with integration Developer CSS style with Bootstrap Yii style.

How we can use ?

    $form->textTypeField($model,'$atrributes',[b]"userLogin"[/b], array(...));

This solution is tested, and my textfield style is imported :)

And what do you think about this solution, you may put it in Yii library?

Ok, i forgot to add that we must create new function activeInputField in CHtml.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users