Home > Article > Backend Development > PHP development framework Yii Framework tutorial (14) UI component MaskedTextField example
CMaskedTextField is a format input box. You can specify a Mask for the text box to restrict the text format that users can enter and exit. For example, using 99.99.9999 in this example can only allow the input of text similar to dates.
Modify View and add CMaskedTextField component
widget ('CMaskedTextField',array('model'=>$model,'attribute'=>'date','name'=>'date','mask'=>'99.99.9999', 'htmlOptions'=>array('style'=>'width:80px;'),));?>
In order to cooperate with CMaskedTextField, we modify DataModel and add an attribute date
class DataModel extends CFormModel{public $date; public function rules(){ return array(array('date', 'safe'),); } }
The above is the content of the PHP development framework Yii Framework tutorial (14) UI component MaskedTextField example. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!