php kahana widget

来源:互联网 发布:usb端口防静电设计 编辑:程序博客网 时间:2024/06/11 23:21
<div class="row">    <?php foreach($template_fields as $key=>$item){?>        <input type="hidden" id="template_<?php echo $item['id']?>" name="template_fields_ids[]" value="<?php echo $item['id']?>"/>        <input type="hidden" id="template_id" name="template_id" value="<?php echo $item['template_id']?>"/>        <?php echo Widget::factory('Product_Tpl_Data', array('tpl_field_orm' => $item)); ?>    <?php }?></div>//.....
Product_Tpl_Datal.php中内容
class Widget_Product_Tpl_Data extends Widget{    /**     * 视图名称     *     * @var string     */    protected $_view_name = 'widget/product/tpl/input';    /**     * 控件属性     *     * @var array     */    protected $_data = array();    /**     * 渲染前置回调     *     * @return void     */    protected function _render_before()    {        $tpl_field_orm = Arr::get($this->_data,'tpl_field_orm');        $field_types = Kohana::config('channel.field_types');        $field_type = Arr::get($field_types,$tpl_field_orm['field_type']);        $this->_view_name = 'widget/product/tpl/' . $field_type;    }}


//.....

widget/product/tpl/text.php
<div class="form-group">    <?php if($tpl_field_orm['is_required'] ==1){?>        <label class="col-md-2 control-label"><span class="required">*</span><?php echo $tpl_field_orm['field_name']?></label>    <?php }else{?>        <label class="col-md-2 control-label"><?php echo $tpl_field_orm['field_name']?></label>    <?php }?>    <div class="col-md-10">        <?php if($tpl_field_orm['is_required'] ==1){?>            <input class="form-control required " onblur="checkText(this)" minlength_self="<?php echo $tpl_field_orm['min_length']?>"  maxlength_self="<?php echo $tpl_field_orm['max_length']?>" id="text_<?php echo $tpl_field_orm['id']?>" name="text_<?php echo $tpl_field_orm['id']?>" value="<?php echo str_replace("\"","&quot;",$tpl_field_orm['default_value']);?>"/>        <?php }else{?>            <input class="form-control " onblur="checkText(this)" minlength_self="<?php echo $tpl_field_orm['min_length']?>"  maxlength_self="<?php echo $tpl_field_orm['max_length']?>"   id="text_<?php echo $tpl_field_orm['id']?>" name="text_<?php echo $tpl_field_orm['id']?>" value="<?php echo str_replace("\"","&quot;",$tpl_field_orm['default_value']);?>"/>        <?php }?>        <span class="help-block"> <?php echo $tpl_field_orm['fill_hint']?> </span>    </div></div>