首頁  >  文章  >  php框架  >  Yii 範本支援原生語法嗎?

Yii 範本支援原生語法嗎?

Guanhui
Guanhui原創
2020-06-08 16:39:562106瀏覽

Yii 範本支援原生語法嗎?

Yii 範本支援原生語法嗎?

Yii模板支援原生語法,因為Yii框架並沒有使用模板引擎,所以能夠在Yii模板中使用原生PHP語法,Yii模板並沒有使用像Smarty那樣將自訂的標籤編譯成PHP,而是PHP原生態語法的封裝。

Yii 範本標籤

#label標籤

<?php echo $form->labelEx($model,&#39;name&#39;); ?>

編譯後:

<label for="Project_name" class="required">项目名称 <span class="required">*</span></label>

文本標籤

<?php echo $form->textField($model,&#39;name&#39;,array(&#39;size&#39;=>60,&#39;maxlength&#39;=>128)); ?>

編譯後:

<input size="60" maxlength="128" name="Project[name]" id="Project_name" type="text">

error標籤

<?php echo $form->error($model,&#39;name&#39;); ?>

編譯後:

<div class="errorMessage">{变量}</div>

textarea標籤

<?php echo $form->textArea($model,&#39;description&#39;,array(&#39;rows&#39;=>6, &#39;cols&#39;=>50)); ?>

編譯後:

<textarea rows="6" cols="50" name="Project[description]" id="Project_description" class="error"></textarea>

hidden標籤

<?php echo $form->hiddenField($model,&#39;create_time&#39;,array(&#39;value&#39;=>time())); ?>

編譯後:

<input value="1376475100" name="Project[create_time]" id="Project_create_time" type="hidden">

password標籤

<?php echo $form->passwordField($model,&#39;password&#39;); ?>

編譯後:

<input name="Project[password]" id="Project_password" type="password">

url標籤

<?php echo $form->urlField($model,&#39;url&#39;); ?>

編譯後:

<input name="Project[url]" id="Project_url" type="url">

radio標籤

<?php echo $form->radioButtonList($model, &#39;update_time&#39;, array(&#39;1&#39;=>&#39;分页&#39;,&#39;0&#39;=>&#39;不分页&#39;)); ?>

編譯後:

<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, &#39;update_time&#39;); ?>

編譯後:

<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 ? &#39;创建&#39; : &#39;保存&#39;); ?>

編譯後:

<input type="submit" name="yt0" value="创建">

checkBox標籤

<?php echo $form->checkBox($model, &#39;update_time&#39;,array(&#39;checked&#39;=>&#39;checked&#39;)); ?>

編譯後:

<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, &#39;update_time&#39;, array(&#39;1&#39;=>&#39;分页&#39;,&#39;0&#39;=>&#39;不分页&#39;)); ?>

編譯後:

<select name="Project[update_time]" id="Project_update_time">
<option value="1">分页</option>
<option value="0">不分页</option>
</select>

select標籤

<?php echo $form->listBox($model, &#39;update_time&#39;, array(&#39;1&#39;=>&#39;分页&#39;,&#39;0&#39;=>&#39;不分页&#39;)); ?>

編譯後:

<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, &#39;update_time&#39;, array(&#39;1&#39;=>&#39;分页&#39;,&#39;0&#39;=>&#39;不分页&#39;)); ?>

編譯後:

<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, &#39;update_time&#39;); ?>

編譯後:

<input name="Project[update_time]" id="Project_update_time" type="date">

number標籤

<?php echo $form->numberField($model, &#39;number&#39;); ?>

編譯後:

<input name="Project[number]" id="Project_number" type="number">

email標籤

<?php echo $form->emailField($model, &#39;email&#39;); ?>

編譯後:

<input name="Project[email]" id="Project_email" type="email">

label標籤

 <?php echo $form->label($model, &#39;update_time&#39;); ?>

編譯後:

<label for="Project_update_time">更新时间</label>

推薦教學:《Yii教學

以上是Yii 範本支援原生語法嗎?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn