Yii 範本支援原生語法嗎?
Yii模板支援原生語法,因為Yii框架並沒有使用模板引擎,所以能夠在Yii模板中使用原生PHP語法,Yii模板並沒有使用像Smarty那樣將自訂的標籤編譯成PHP,而是PHP原生態語法的封裝。
Yii 範本標籤
#label標籤
<?php echo $form->labelEx($model,'name'); ?>
編譯後:
<label for="Project_name" class="required">项目名称 <span class="required">*</span></label>
文本標籤
<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>128)); ?>
編譯後:
<input size="60" maxlength="128" name="Project[name]" id="Project_name" type="text">
error標籤
<?php echo $form->error($model,'name'); ?>
編譯後:
<div class="errorMessage">{变量}</div>
textarea標籤
<?php echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>
編譯後:
<textarea rows="6" cols="50" name="Project[description]" id="Project_description" class="error"></textarea>
hidden標籤
<?php echo $form->hiddenField($model,'create_time',array('value'=>time())); ?>
編譯後:
<input value="1376475100" name="Project[create_time]" id="Project_create_time" type="hidden">
password標籤
<?php echo $form->passwordField($model,'password'); ?>
編譯後:
<input name="Project[password]" id="Project_password" type="password">
url標籤
<?php echo $form->urlField($model,'url'); ?>
編譯後:
<input name="Project[url]" id="Project_url" type="url">
radio標籤
<?php echo $form->radioButtonList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>
編譯後:
<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]"> <span id="Project_update_time"><input id="Project_update_time_0" value="1" type="radio" name="Project[update_time]"> <label for="Project_update_time_0">分页</label><br> <input id="Project_update_time_1" value="0" type="radio" name="Project[update_time]"> <label for="Project_update_time_1">不分页</label></span>
file標籤
<?php echo $form->fileField($model, 'update_time'); ?>
編譯後:
<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]"> <input name="Project[update_time]" id="Project_update_time" type="file">
button標籤
<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
編譯後:
<input type="submit" name="yt0" value="创建">
checkBox標籤
<?php echo $form->checkBox($model, 'update_time',array('checked'=>'checked')); ?>
編譯後:
<input id="ytProject_update_time" type="hidden" value="0" name="Project[update_time]"> <input checked="checked" name="Project[update_time]" id="Project_update_time" value="1" type="checkbox">
select標籤
<?php echo $form->dropDownList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>
編譯後:
<select name="Project[update_time]" id="Project_update_time"> <option value="1">分页</option> <option value="0">不分页</option> </select>
select標籤
<?php echo $form->listBox($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>
編譯後:
<select size="4" name="Project[update_time]" id="Project_update_time"> <option value="1">分页</option> <option value="0">不分页</option> </select>
checkbox標籤
<?php echo $form->checkBoxList($model, 'update_time', array('1'=>'分页','0'=>'不分页')); ?>
編譯後:
<input id="ytProject_update_time" type="hidden" value="" name="Project[update_time]"><span id="Project_update_time"><input id="Project_update_time_0" value="1" type="checkbox" name="Project[update_time][]"> <label for="Project_update_time_0">分页</label><br> <input id="Project_update_time_1" value="0" type="checkbox" name="Project[update_time][]"> <label for="Project_update_time_1">不分页</label></span>
date標籤
<?php echo $form->dateField($model, 'update_time'); ?>
編譯後:
<input name="Project[update_time]" id="Project_update_time" type="date">
number標籤
<?php echo $form->numberField($model, 'number'); ?>
編譯後:
<input name="Project[number]" id="Project_number" type="number">
email標籤
<?php echo $form->emailField($model, 'email'); ?>
編譯後:
<input name="Project[email]" id="Project_email" type="email">
label標籤
<?php echo $form->label($model, 'update_time'); ?>
編譯後:
<label for="Project_update_time">更新时间</label>
推薦教學:《Yii教學》
以上是Yii 範本支援原生語法嗎?的詳細內容。更多資訊請關注PHP中文網其他相關文章!