Yii Framework Forum: Custom Textfield Type - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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

Hi!

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:

CAvtiveForm:

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


CHtml

public function activeTypeTextField($model,$attribute,$type,$htmlOptions=array())
{
    self::resolveNameId($model,$attribute,$htmlOptions);
    self:clientChange('cjange',$htmlOptions);
    return self::activeInputField($type,$model,$attribute,$htmlOptions);
}


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

How we can use ?

  View.php
  
   ...
    $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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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