溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Yii模板能不能夠支持原生語法

發(fā)布時間:2021-01-16 10:03:02 來源:億速云 閱讀:176 作者:小新 欄目:編程語言

這篇文章給大家分享的是有關(guān)Yii模板能不能夠支持原生語法的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

Yii 模板支持原生語法嗎?

Yii模板支持原生語法,因?yàn)閅ii框架并沒有使用模板引擎,所以能夠在Yii模板中使用原生PHP語法,Yii模板并沒有使用像Smarty那樣將自定義的標(biāo)簽編譯成PHP,而是對PHP原生態(tài)語法的封裝。

Yii 模板標(biāo)簽

label標(biāo)簽

<?php echo $form->labelEx($model,'name'); ?>

編譯后:

<label for="Project_name" class="required">項(xiàng)目名稱 <span class="required">*</span></label>

文本標(biāo)簽

<?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標(biāo)簽

<?php echo $form->error($model,'name'); ?>

編譯后:

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

textarea標(biāo)簽

<?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標(biāo)簽

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

編譯后:

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

password標(biāo)簽

<?php echo $form->passwordField($model,'password'); ?>

編譯后:

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

url標(biāo)簽

<?php echo $form->urlField($model,'url'); ?>

編譯后:

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

radio標(biāo)簽

<?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標(biāo)簽

<?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標(biāo)簽

<?php echo CHtml::submitButton($model->isNewRecord ? '創(chuàng)建' : '保存'); ?>

編譯后:

<input type="submit" name="yt0" value="創(chuàng)建">

checkBox標(biāo)簽

<?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標(biāo)簽

<?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標(biāo)簽

<?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標(biāo)簽

<?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標(biāo)簽

 <?php echo $form->dateField($model, 'update_time'); ?>

編譯后:

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

number標(biāo)簽

<?php echo $form->numberField($model, 'number'); ?>

編譯后:

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

email標(biāo)簽

<?php echo $form->emailField($model, 'email'); ?>

編譯后:

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

label標(biāo)簽

 <?php echo $form->label($model, 'update_time'); ?>

編譯后:

<label for="Project_update_time">更新時間</label>

感謝各位的閱讀!關(guān)于“Yii模板能不能夠支持原生語法”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

yii
AI