這篇文章給大家分享的是有關(guān)Yii模板能不能夠支持原生語法的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
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">更新時(shí)間</label>
感謝各位的閱讀!關(guān)于“Yii模板能不能夠支持原生語法”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
分享標(biāo)題:Yii模板能不能夠支持原生語法-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://vcdvsql.cn/article36/ceoipg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)站內(nèi)鏈、手機(jī)網(wǎng)站建設(shè)、ChatGPT、服務(wù)器托管、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容