首页  >  文章  >  php框架  >  Yii 模板支持原生语法吗?

Yii 模板支持原生语法吗?

Guanhui
Guanhui原创
2020-06-08 16:39:562085浏览

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