Home  >  Article  >  Backend Development  >  PHP development framework Yii Framework tutorial (14) UI component MaskedTextField example

PHP development framework Yii Framework tutorial (14) UI component MaskedTextField example

黄舟
黄舟Original
2017-01-21 10:16:191140browse

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'),);
}
}

PHP development framework Yii Framework tutorial (14) UI component MaskedTextField example

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)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn