php kahana widget

<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 " οnblur="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 " οnblur="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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值